public void ShowObserverView(MyAbstractObserver observer) { MyNode owner = null; if (observer is MyAbstractMemoryBlockObserver) { owner = (observer as MyAbstractMemoryBlockObserver).Target.Owner; } else if (observer is MyTimePlotObserver) { owner = (observer as MyTimePlotObserver).Target.Owner; } else { owner = observer.GenericTarget as MyNode; } ObserverForm newView = new ObserverForm(this, observer, owner); ObserverViews.Add(newView); newView.Show(dockPanel, DockState.Float); newView.FloatPane.FloatWindow.Size = new Size((int)observer.WindowSize.Width, (int)observer.WindowSize.Height); newView.FloatPane.FloatWindow.Location = new Point((int)observer.WindowLocation.X, (int)observer.WindowLocation.Y); if (!SystemInformation.VirtualScreen.Contains(newView.FloatPane.FloatWindow.Bounds)) { newView.FloatPane.FloatWindow.Location = new Point(0, 0); } }
public void CreateAndShowObserverView(MyWorkingNode node, Type observerType) { try { MyAbstractObserver observer = (MyAbstractObserver)Activator.CreateInstance(observerType); observer.GenericTarget = node; ObserverForm newView = new ObserverForm(this, observer, node); ObserverViews.Add(newView); newView.Show(dockPanel, DockState.Float); } catch (Exception e) { MyLog.ERROR.WriteLine("Error creating observer: " + e.Message); } }
public void CreateAndShowObserverView(MyAbstractMemoryBlock memoryBlock, MyNode declaredOwner, Type mbObserverType) { bool isPlot = mbObserverType == typeof(MyTimePlotObserver); if (isPlot && !(memoryBlock is MyMemoryBlock <float>)) { MyLog.ERROR.WriteLine("Plot observers are not allowed for non-float memory blocks"); return; } try { MyAbstractObserver observer; if (isPlot) { MyTimePlotObserver plotObserver = new MyTimePlotObserver(); plotObserver.Target = (MyMemoryBlock <float>)memoryBlock; observer = plotObserver; } else { MyAbstractMemoryBlockObserver memObserver = (MyAbstractMemoryBlockObserver)Activator.CreateInstance(mbObserverType); memObserver.Target = memoryBlock; observer = memObserver; } ObserverForm newView = new ObserverForm(this, observer, declaredOwner); ObserverViews.Add(newView); newView.Show(dockPanel, DockState.Float); } catch (Exception e) { MyLog.ERROR.WriteLine("Error creating observer: " + e.Message); } }
private void SetObserver() { if (m_showObserver && m_school != null) { if (m_observer == null) { try { MyMemoryBlockObserver observer = new MyMemoryBlockObserver(); observer.Target = m_school.VisualFOV; m_observer = new ObserverForm(m_mainForm, observer, m_school); m_observer.TopLevel = false; dockPanelObserver.Controls.Add(m_observer); m_observer.CloseButtonVisible = false; m_observer.MaximizeBox = false; m_observer.Size = dockPanelObserver.Size + new System.Drawing.Size(16, 38); m_observer.Location = new System.Drawing.Point(-8, -30); m_observer.Show(); } catch (Exception e) { MyLog.ERROR.WriteLine("Error creating observer: " + e.Message); } } else { m_observer.Show(); dockPanelObserver.Show(); m_observer.Observer.GenericTarget = m_school.VisualFOV; } } else { if (m_observer != null) { //(m_observer.Observer as MyMemoryBlockObserver).Target = null; m_observer.Close(); m_observer.Dispose(); m_observer = null; dockPanelObserver.Hide(); } } }
public void RemoveObserverView(ObserverForm view) { ObserverViews.Remove(view); }
public void RemoveObserverView(ObserverForm view) { ObserverViews.Remove(view); ProjectStateChanged("Abstract removed"); }
public void ShowObserverView(MyAbstractObserver observer) { MyNode owner; var blockObserver = observer as MyAbstractMemoryBlockObserver; if (blockObserver != null) { owner = blockObserver.Target.Owner; } else { var plotObserver = observer as MyTimePlotObserver; if (plotObserver != null) { owner = plotObserver.Target.Owner; } else { owner = observer.GenericTarget as MyNode; } } var newView = new ObserverForm(this, observer, owner); ObserverViews.Add(newView); // This is only called from deserialization, the state saving would be redundant. //ProjectStateChanged("Abstract observer added"); newView.Show(dockPanel, DockState.Float); newView.FloatPane.FloatWindow.Size = new Size((int)observer.WindowSize.Width, (int)observer.WindowSize.Height); newView.FloatPane.FloatWindow.Location = new Point((int)observer.WindowLocation.X, (int)observer.WindowLocation.Y); if (!SystemInformation.VirtualScreen.Contains(newView.FloatPane.FloatWindow.Bounds)) { newView.FloatPane.FloatWindow.Location = new Point(0, 0); } }
public void CreateAndShowObserverView(MyAbstractMemoryBlock memoryBlock, MyNode declaredOwner, Type mbObserverType) { bool isPlot = mbObserverType == typeof(MyTimePlotObserver) || mbObserverType == typeof(TimePlotObserver); if (isPlot && !(memoryBlock is MyMemoryBlock<float>)) { MyLog.ERROR.WriteLine("Plot observers are not allowed for non-float memory blocks"); return; } try { MyAbstractObserver observer = null; if (isPlot) { if (mbObserverType == typeof(MyTimePlotObserver)) { observer = new MyTimePlotObserver { Target = (MyMemoryBlock<float>)memoryBlock }; } else if (mbObserverType == typeof(TimePlotObserver)) { observer = new TimePlotObserver { Target = (MyMemoryBlock<float>)memoryBlock }; } } else { MyAbstractMemoryBlockObserver memObserver = (MyAbstractMemoryBlockObserver)Activator.CreateInstance(mbObserverType); memObserver.Target = memoryBlock; observer = memObserver; } if (observer == null) throw new InvalidOperationException("No observer was initialized"); ObserverForm newView = new ObserverForm(this, observer, declaredOwner); ObserverViews.Add(newView); newView.Show(dockPanel, DockState.Float); ProjectStateChanged("Memory block observer added"); } catch (Exception e) { MyLog.ERROR.WriteLine("Error creating observer: " + e.Message); } }
public void CreateAndShowObserverView(MyWorkingNode node, Type observerType) { try { MyAbstractObserver observer = (MyAbstractObserver)Activator.CreateInstance(observerType); observer.GenericTarget = node; ObserverForm newView = new ObserverForm(this, observer, node); ObserverViews.Add(newView); newView.Show(dockPanel, DockState.Float); ProjectStateChanged("Node observer added"); } catch (Exception e) { MyLog.ERROR.WriteLine("Error creating observer: " + e.Message); } }
public void CreateAndShowObserverView(MyAbstractMemoryBlock memoryBlock, MyNode declaredOwner, Type mbObserverType) { bool isPlot = mbObserverType == typeof(MyTimePlotObserver); if (isPlot && !(memoryBlock is MyMemoryBlock<float>)) { MyLog.ERROR.WriteLine("Plot observers are not allowed for non-float memory blocks"); return; } try { MyAbstractObserver observer; if (isPlot) { MyTimePlotObserver plotObserver = new MyTimePlotObserver(); plotObserver.Target = (MyMemoryBlock<float>)memoryBlock; observer = plotObserver; } else { MyAbstractMemoryBlockObserver memObserver = (MyAbstractMemoryBlockObserver)Activator.CreateInstance(mbObserverType); memObserver.Target = memoryBlock; observer = memObserver; } ObserverForm newView = new ObserverForm(this, observer, declaredOwner); ObserverViews.Add(newView); newView.Show(dockPanel, DockState.Float); } catch (Exception e) { MyLog.ERROR.WriteLine("Error creating observer: " + e.Message); } }