public tstLink(IProject project, IDock master, IDock slave) { _project = project; _delay = 0; }
internal bool DockDockableIntoDock(IDockable sourceDockable, IDock sourceDockableOwner, IDock targetDock, DragAction action, DockOperation operation, bool bExecute) { switch (action) { case DragAction.Copy: return(false); case DragAction.Move: return(DockDockable(sourceDockable, sourceDockableOwner, targetDock, operation, bExecute)); case DragAction.Link: return(SwapDockable(sourceDockable, sourceDockableOwner, targetDock, bExecute)); default: return(false); } }
private bool Validate(IDock layout, object context, object sender, DragEventArgs e, bool bExecute) { var point = DropHelper.GetPosition(sender, e); switch (sender) { case TabStrip strip: return(ValidateTabStrip(layout, e, bExecute, strip)); case DockPanel panel: return(ValidateDockPanel(layout, e, bExecute, panel)); } if (e.Data.Get(DragDataFormats.Parent) is TabStripItem item) { var strip = item.Parent as TabStrip; if (strip.DataContext is IDock container) { if (bExecute) { int itemIndex = strip.ItemContainerGenerator.IndexFromContainer(item); var position = DropHelper.GetPositionScreen(sender, e); // WIP: This is work in progress. //var splitLayout = container.SplitLayout(context, SplitDirection.Left); //layout.ReplaceView(container, splitLayout); var window = layout.CurrentView.CreateWindow(container, itemIndex, context); window.X = position.X; window.Y = position.Y; window.Width = 300; window.Height = 400; window.Id = "Dock"; window.Title = "Dock"; window.Layout.Title = "Dock"; window.Present(false); return(true); } return(true); } } return(false); }
private void DeserializeChildren(IDock dock, SerializedDock serializedDock) { dock.VisibleDockables = dockFactory.CreateList <IDockable>(); if (serializedDock.Children == null) { return; } foreach (var dockable in serializedDock.Children) { var deserialized = DeserializeDockable(dockable); if (deserialized != null) { dock.VisibleDockables.Add(deserialized); } } }
public void AddTool(IDock layout, AvaloniaToolDockWrapper toolWrapper) { var toolDock = FindDockable(layout, dockable => dockable is ToolDock) as ToolDock; if (toolDock == null) { toolDock = new ToolDock { Id = "tool", Title = "Tools", Proportion = 0.2f, }; AddDockable(layout, CreateSplitterDockable()); AddDockable(layout, toolDock); } AddDockable(toolDock, toolWrapper); }
/// <summary> /// Creates a gizmo using the specified type. /// </summary> /// <param name="dock">The dock that's hosting the gizmo.</param> /// <param name="type">A Gizmo-derived type.</param> /// <param name="instanceName">The instance name to use.</param> /// <param name="errors">A collection to add error message to if necessary.</param> /// <returns>A new gizmo instance if it was created successfully. /// Null if errors were added to the <paramref name="errors"/> collection.</returns> public static Gizmo Create(IDock dock, Type type, string instanceName, IList <string> errors) { Conditions.RequireReference(dock, () => dock); Conditions.RequireReference(type, () => type); Gizmo result = null; if (!type.IsSubclassOf(typeof(Gizmo))) { errors.Add("Type " + type.FullName + " does not derive from " + typeof(Gizmo).FullName); } else { GizmoInfo info = new GizmoInfo(type); if (info.IsSingleInstance && !string.IsNullOrEmpty(instanceName)) { errors.Add(info.GizmoName + " is a single instance gizmo, so an instance name isn't supported."); } else if (!info.IsSingleInstance && string.IsNullOrEmpty(instanceName)) { errors.Add(info.GizmoName + " is a multi-instance gizmo, so an instance name is required."); } else { try { result = (Gizmo)Activator.CreateInstance(type); result.gizmoInfo = info; result.Dock = dock; result.InstanceName = instanceName; } catch (MissingMethodException ex) { errors.Add(ex.Message); } catch (TargetInvocationException ex) { errors.Add(ex.GetBaseException().Message); } } } return(result); }
/// <inheritdoc/> public virtual void SplitToWindow(IDock dock) { if (FindRoot(dock) is IDock root && root.CurrentView is IDock currentViewRoot) { RemoveView(dock); var window = CreateWindowFrom(dock); if (window != null) { AddWindow(currentViewRoot, window, dock.Context); window.X = 0; window.Y = 0; window.Width = 300; window.Height = 400; window.Present(false); } } }
/// <inheritdoc/> public virtual void Split(IDock dock, IView view, DockOperation operation) { switch (operation) { case DockOperation.Left: case DockOperation.Right: case DockOperation.Top: case DockOperation.Bottom: { var layout = CreateSplitLayout(dock, view, dock.Context, operation); Replace(dock, layout); Update(layout, dock.Context, dock.Parent); } break; default: throw new NotSupportedException($"Not support dock operation: {operation}."); } }
private bool ValidateDockPanel(IDock layout, DragEventArgs e, bool bExecute, DockPanel panel) { var sourceItem = e.Data.Get(DragDataFormats.Parent); if (sourceItem is TabStripItem source && source.Parent is TabStrip sourceStrip && sourceStrip.DataContext is IDock sourceLayout && panel.DataContext is IDock targetLayout && sourceLayout != targetLayout) { int sourceIndex = sourceStrip.ItemContainerGenerator.IndexFromContainer(source); int targetIndex = targetLayout.Views.Count; if (e.DragEffects == DragDropEffects.Copy) { if (bExecute) { // TODO: Clone item. } return(true); } else if (e.DragEffects == DragDropEffects.Move) { if (bExecute) { sourceLayout.MoveView(targetLayout, sourceIndex, targetIndex); } return(true); } else if (e.DragEffects == DragDropEffects.Link) { if (bExecute) { sourceLayout.SwapView(targetLayout, sourceIndex, targetIndex); } return(true); } return(false); } return(false); }
private void WriteWindows(string indent, string valueId, IDock dock) { if (dock.Windows != null && dock.Windows.Count > 0) { Output($"{indent}{valueId}.Windows = CreateList<IDockWindow>();"); foreach (var window in dock.Windows) { Output($"{indent}{valueId}.Windows.Add({_idWindows[window]});"); } foreach (var window in dock.Windows) { if (window.Layout != null) { Output($"{indent}{_idWindows[window]}.Layout = {_idViews[window.Layout]};"); } } } }
public void RemoveDock(IDock dock) { if (dock == _left) { _left = null; } else if (dock == _right) { _right = null; } else if (dock == _bottom) { _bottom = null; } else if (dock == _top) { _top = null; } }
/// <summary> /// WIP: Replaces view. /// </summary> /// <param name="root">The root dock.</param> /// <param name="source">The source dock.</param> /// <param name="target">The target dock.</param> /// <returns>True when view was replaced, otherwise false.</returns> public static bool ReplaceView(this IDock root, IDock source, IDock target) { if (root.Views != null) { for (int i = 0; i < root.Views.Count; i++) { if (root.Views[i] == source) { root.Views[i] = target; return(true); } if (ReplaceView(root.Views[i], source, target) == true) { return(true); } } } return(false); }
private void WriteDock(IDock root, string indent = "") { string id = $"view{_viewCount}"; _viewCount++; if (!_idViews.ContainsKey(root)) { _idViews[root] = id; } Output($"{indent}var {id} = new {root.GetType().Name}()"); Output($"{indent}{{"); Output($"{indent} Id = \"{root.Id}\","); Output($"{indent} Width = {FormatDouble(root.Width)},"); Output($"{indent} Height = {FormatDouble(root.Height)},"); Output($"{indent} Title = \"{root.Title}\","); Output($"{indent} Dock = \"{root.Dock}\","); Output($"{indent}}};"); if (root.Views != null) { foreach (var view in root.Views) { if (view is IDock dock) { WriteDock(dock, indent); } else { WriteView(view, indent); } } } if (root.Windows != null) { foreach (var window in root.Windows) { WriteWindow(window, indent); } } }
/// <inheritdoc /> public void SetFocusedDockable(IDock dock, IDockable dockable) { if (dock.ActiveDockable != null && FindRoot(dock.ActiveDockable) is IRootDock root) { if (root.FocusedDockable != null) { SetIsActive(root.FocusedDockable.Owner, false); } if (dockable != null) { root.FocusedDockable = dockable; } if (root.FocusedDockable != null) { SetIsActive(root.FocusedDockable.Owner, true); } } }
internal bool DockDockable(IDockable sourceDockable, IDock sourceDockableOwner, IDock targetDock, DockOperation operation, bool bExecute) { switch (operation) { case DockOperation.Fill: return(MoveDockable(sourceDockable, sourceDockableOwner, targetDock, bExecute)); case DockOperation.Left: case DockOperation.Right: case DockOperation.Top: case DockOperation.Bottom: return(SplitDockable(sourceDockable, sourceDockableOwner, targetDock, operation, bExecute)); case DockOperation.Window: return(DockDockableIntoWindow(sourceDockable, targetDock, operation, bExecute)); default: return(false); } }
///<inheritdoc/> public void SetFocusedDockable(IDock dock, IDockable dockable) { if (!(dock.ActiveDockable is null) && FindRoot(dockable) is IRootDock root) { if (!(root.FocausedDockable?.Owner is null)) { SetIsActive(root.FocausedDockable.Owner, false); } if (!(dock is null)) { root.FocausedDockable = dockable; } if (!(root.FocausedDockable?.Owner is null)) { SetIsActive(root.FocausedDockable.Owner, true); } } }
private void SplitDocumentDockable(IDockable sourceDockable, IDock sourceDockableOwner, IDock targetDock, DockOperation operation) { if (targetDock.Factory is not { } factory) { return; } IDocumentDock documentDock = factory.CreateDocumentDock(); documentDock.Id = nameof(IDocumentDock); documentDock.Title = nameof(IDocumentDock); documentDock.VisibleDockables = factory.CreateList <IDockable>(); if (sourceDockableOwner is IDocumentDock sourceDocumentDock) { documentDock.CanCreateDocument = sourceDocumentDock.CanCreateDocument; } factory.MoveDockable(sourceDockableOwner, documentDock, sourceDockable, null); factory.SplitToDock(targetDock, documentDock, operation); }
public static bool Equal(IDock dock1, IDock dock2) { if (dock1.GetType() != dock2.GetType()) { return(false); } if (dock1.Id != dock2.Id) { return(false); } if (!Enumerable.SequenceEqual(dock1.VisibleDockables, dock2.VisibleDockables, dockableComparer)) { return(false); } if (!Enumerable.SequenceEqual(dock1.HiddenDockables, dock2.HiddenDockables, dockableComparer)) { return(false); } if (dock1.PinnedDockables != null && dock2.PinnedDockables != null) { if (!Enumerable.SequenceEqual(dock1.PinnedDockables, dock2.PinnedDockables, dockableComparer)) { return(false); } } if (!Equal(dock1.ActiveDockable, dock2.ActiveDockable)) { return(false); } if (!Equal(dock1.FocusedDockable, dock2.FocusedDockable)) { return(false); } if (dock1.IsActive != dock2.IsActive) { return(false); } return(true); }
/// <summary> /// Creates a gizmo using the specified assembly and type names. /// </summary> /// <param name="dock">The dock that's hosting the gizmo.</param> /// <param name="assemblyName">The name of the assembly to load.</param> /// <param name="typeName">The name of the type to load from the specified assembly.</param> /// <param name="instanceName">The instance name to use.</param> /// <param name="errors">A collection to add error message to if necessary.</param> /// <returns>A new gizmo instance if it was created successfully. /// Null if errors were added to the <paramref name="errors"/> collection.</returns> public static Gizmo Create(IDock dock, string assemblyName, string typeName, string instanceName, IList <string> errors) { Conditions.RequireReference(dock, () => dock); Conditions.RequireString(typeName, () => typeName); Gizmo result = null; Assembly assembly = LoadAssembly(assemblyName, errors); if (assembly != null) { Type type = assembly.GetType(typeName, false); if (type == null) { // If they didn't give us a fully-qualified name, look for matching class names. var types = assembly.ExportedTypes.Where(t => t.Name == typeName); switch (types.Count()) { case 0: errors.Add("Unable to find a type named " + typeName + " in the specified assembly."); break; case 1: type = types.First(); break; default: errors.Add( "More than one type named " + typeName + " exists in the specified assembly. Please use a namespace-qualified type name."); break; } } if (type != null) { result = Create(dock, type, instanceName, errors); } } return(result); }
private void WriteViews(string indent, string valueId, IDock dock) { if (dock.Views != null && dock.Views.Count > 0) { if (dock.CurrentView != null) { Output($"{indent}{valueId}.CurrentView = {_idViews[dock.CurrentView]};"); } if (dock.DefaultView != null) { Output($"{indent}{valueId}.DefaultView = {_idViews[dock.DefaultView]};"); } Output($"{indent}{valueId}.Views = CreateList<IView>();"); foreach (var view in dock.Views) { Output($"{indent}{valueId}.Views.Add({_idViews[view]});"); } } }
/// <summary> /// Move views in the dock. /// </summary> /// <param name="dock">The views dock.</param> /// <param name="sourceIndex">The source view index.</param> /// <param name="targetIndex">The target view index.</param> public static void MoveView(this IDock dock, int sourceIndex, int targetIndex) { if (sourceIndex < targetIndex) { var item = dock.Views[sourceIndex]; dock.Views.RemoveAt(sourceIndex); dock.Views.Insert(targetIndex, item); dock.CurrentView = item; } else { int removeIndex = sourceIndex; if (dock.Views.Count > removeIndex) { var item = dock.Views[sourceIndex]; dock.Views.RemoveAt(removeIndex); dock.Views.Insert(targetIndex, item); dock.CurrentView = item; } } }
internal bool SwapDockable(IDockable sourceDockable, IDock sourceDockableOwner, IDock targetDock, bool bExecute) { var targetDockable = targetDock.ActiveDockable; if (targetDock is null) { targetDockable = targetDock.VisibleDockables.LastOrDefault(); if (targetDockable is null) { return(false); } } if (bExecute) { if (sourceDockable.Factory is IFactory factory) { factory.SwapDockable(sourceDockableOwner, targetDock, sourceDockable, targetDockable); } } return(true); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MenuItem_Click(object sender, EventArgs e) { try { IDock dock = null; if (sender == tsmiSubdepo) { dock = (IDock)Activator.CreateInstance(Type.GetType("InFresh.Master.v1.Pages.MP001_SubdepoPage")); } else if (sender == tsmiEmployee) { dock = (IDock)Activator.CreateInstance(Type.GetType("InFresh.Master.v1.Pages.MP002_EmployeePage")); } else if (sender == tsmiSupplier) { dock = (IDock)Activator.CreateInstance(Type.GetType("InFresh.Master.v1.Pages.MP003_SupplierPage")); } else if (sender == tsmiOutlet) { dock = (IDock)Activator.CreateInstance(Type.GetType("InFresh.Master.v1.Pages.MP004_OutletPage")); } if (dock != null) { MasterModule.Handler.Host.ShowContent(dock as DockContent, dock.State); } } catch (Exception ex) { MessageBox.Show(null, ex.Message, MasterModule.Name, MessageBoxButtons.OK, MessageBoxIcon.Information); } //MessageBox.Show("Hello Menu " + (sender as ToolStripMenuItem).Text.Replace("&", string.Empty)); //if (sender == tsmiSubdepo) //{ // MessageBox.Show("Hello Menu Master Subdepo"); // return; //} }
public void subscribe(IDock master, IDock slave) { masterMbr = new alter.Link.classes.LinkMember( new alter.Function.classes.VectorF() { Date = alter.classes.Hlp.InitDate, Direction = e_Direction.Fixed }, dependDotMst() ); masterMbr.SetInfo(master); masterMbr.SetDependType(e_DependType.Master); dotMaster = master.Subscribe(e_DependType.Master, this); masterMbr.Depend.SetDate(() => dotMaster.GetDate()); masterMbr.Depend.SetDependDot(() => dependDotMst()); master.event_ObjectDeleted += onDeleteTask; dotMaster.event_DateChanged += onMasterDateChange; slaveMbr = new alter.Link.classes.LinkMember( new alter.Function.classes.VectorF() { Date = getDateLimit(), Direction = e_Direction.Fixed }, dependDotSlv() ); slaveMbr.SetInfo(slave); slaveMbr.SetDependType(e_DependType.Slave); dotSlave = slave.Subscribe(e_DependType.Slave, this); }
///<inheritdoc/> public bool ValidateDock(IDock sourceDock, IDockable targetDockable, DragAction action, DockOperation operation, bool bExecute) { switch (targetDockable) { case IRootDock _: return(DockDockableIntoWindow(sourceDock, targetDockable, operation, bExecute)); case IToolDock toolDock: if (sourceDock == toolDock) { return(false); } return(DockDockable(sourceDock, targetDockable, toolDock, action, operation, bExecute)); case IDocumentDock documentDock: if (sourceDock == documentDock) { return(false); } return(DockDockable(sourceDock, targetDockable, documentDock, action, operation, bExecute)); case IPinDock pinDock: if (sourceDock == pinDock) { return(false); } return(DockDockable(sourceDock, targetDockable, pinDock, action, operation, bExecute)); case IProportionalDock proportionalDock: if (sourceDock == proportionalDock) { return(false); } return(DockDockable(sourceDock, targetDockable, proportionalDock, action, operation, bExecute)); default: return(false); } }
public void Should_leverage_repository_to_find_dock() { long dockId = 1; IDock dock = _mockery.DynamicMock <IDock>( ); ISlip slip = _mockery.DynamicMock <ISlip>( ); IList <ISlip> availableSlipsForDock = new List <ISlip>( ); availableSlipsForDock.Add(slip); SlipDisplayDTO dto = ObjectMother.SlipDisplayDTO( ); using (_mockery.Record( )) { Expect.Call(_dockRepository.FindBy(dockId)).Return(dock); Expect.Call(_slipRepository.AllAvailableSlipsFor(dock)).Return(availableSlipsForDock); Expect.Call(_slipMapper.MapFrom(slip)).Return(dto); } using (_mockery.Playback( )) { IRichList <SlipDisplayDTO> slipsFound = ListFactory.From(CreateSUT( ).GetAvailableSlipsForDockBy(dockId)); Assert.IsTrue(slipsFound.Contains(dto)); } }
/// <inheritdoc/> public virtual void MoveView(IDock sourceDock, IDock targetDock, IView sourceView, IView targetView) { RemoveView(sourceView); if (targetDock.Views == null) { targetDock.Views = CreateList <IView>(); } int targetIndex = targetDock.Views.IndexOf(targetView); if (targetIndex < 0) { targetIndex = 0; } else { targetIndex += 1; } targetDock.Views.Insert(targetIndex, sourceView); Update(sourceView, sourceView.Context, targetDock); targetDock.CurrentView = sourceView; }
internal bool SplitDockable(IDockable sourceDockable, IDock sourceDockableOwner, IDock targetDock, DockOperation operation, bool bExecute) { switch (sourceDockable) { case ITool _: if (sourceDockableOwner == targetDock) { if (targetDock.VisibleDockables?.Count == 1) { return(false); } } if (bExecute) { SplitToolDockable(sourceDockable, sourceDockableOwner, targetDock, operation); } return(true); case IDocument _: if (sourceDockableOwner == targetDock) { if (targetDock.VisibleDockables?.Count == 1) { return(false); } } if (bExecute) { SplitDocumentDockable(sourceDockable, sourceDockableOwner, targetDock, operation); } return(true); default: return(false); } }
private void Collapse(IDock dock) { if (dock.IsCollapsable && dock.Views.Count == 0) { if (dock.Parent is IDock parentDock) { var toRemove = new List <IView>(); var dockIndex = parentDock.Views.IndexOf(dock); if (dockIndex > 0 && parentDock.Views[dockIndex - 1] is ISplitterDock splitterPrevious) { toRemove.Add(splitterPrevious); } if (dockIndex < parentDock.Views.Count - 1 && parentDock.Views[dockIndex + 1] is ISplitterDock splitterNext) { toRemove.Add(splitterNext); } foreach (var removeView in toRemove) { RemoveView(removeView); } } if (dock is IRootDock rootDock && rootDock.Window != null) { RemoveWindow(rootDock.Window); } else { RemoveView(dock); } }
public void initUnsuscribe(IDock dock, e_DependType type) { }
/// <summary> /// Clones common dock properties. /// </summary> /// <param name="source">The source object.</param> /// <param name="target">The target object.</param> public static void CloneDockProperties(IDock source, IDock target) { target.Id = source.Id; target.Title = source.Title; target.Proportion = source.Proportion; target.IsActive = source.IsActive; target.IsCollapsable = source.IsCollapsable; if (source.VisibleDockables != null) { target.VisibleDockables = source.Factory.CreateList <IDockable>(); foreach (var visible in source.VisibleDockables) { target.VisibleDockables.Add(visible.Clone()); } } if (source.HiddenDockables != null) { target.HiddenDockables = source.Factory.CreateList <IDockable>(); foreach (var hidden in source.HiddenDockables) { target.HiddenDockables.Add(hidden.Clone()); } } if (source.PinnedDockables != null) { target.PinnedDockables = source.Factory.CreateList <IDockable>(); foreach (var pinned in source.PinnedDockables) { target.PinnedDockables.Add(pinned.Clone()); } } if (source.VisibleDockables != null) { int indexActiveDockable = source.VisibleDockables.IndexOf(source.ActiveDockable); if (indexActiveDockable >= 0) { target.ActiveDockable = target.VisibleDockables[indexActiveDockable]; } int indexDefaultDockable = source.VisibleDockables.IndexOf(source.DefaultDockable); if (indexDefaultDockable >= 0) { target.DefaultDockable = target.VisibleDockables[indexDefaultDockable]; } int indexFocusedDockable = source.VisibleDockables.IndexOf(source.FocusedDockable); if (indexFocusedDockable >= 0) { target.FocusedDockable = target.VisibleDockables[indexFocusedDockable]; } } if (source.Windows != null) { target.Windows = source.Factory.CreateList <IDockWindow>(); foreach (var window in source.Windows) { target.Windows.Add(window.Clone()); } } }
/// <summary> /// Initialize new Instance of the <see cref="NavigateAdapter"/> /// </summary> /// <param name="dock"></param> public NavigateAdapter(IDock dock) { _back = new Stack <IDockable>(); _forward = new Stack <IDockable>(); _dock = dock; }
/// <summary> /// Конструктор экземпляра связи /// </summary> /// <param name="master">Интерфейс управляющего члена связи</param> /// <param name="slave">Интерфейс подчиеннного члена связи</param> /// <param name="limitType">Вид связи</param> public link(IDock master, IDock slave, e_TskLim limitType) :this(master, slave, limitType, 0) { }
/// <summary> /// Конструктор экземпляра связи /// </summary> /// <param name="master">Интерфейс управляющего члена связи</param> /// <param name="slave">Интерфейс подчиеннного члена связи</param> /// <param name="limitType">Вид связи</param> /// <param name="delay">Задержка связи</param> public link(IDock master, IDock slave, e_TskLim limitType, double delay) { init_default(limitType, delay); init_master(master, master); init_slave(slave, slave); init_slaveDependence(); master.connect(this); slave.connect(this); }
public SerializedDock?Serialize(IDock dock) { alreadySerializedDocument = false; return(SerializeDockable(dock)); }
public bool AddInGroup(IDock newObject) { throw new NotImplementedException(); }