Esempio n. 1
0
        public void WhenCalledConvert_CreatesNewViewOrReturnsCachedOneIfAny()
        {
            var converter = new EditorSelector();
            var privateAccessor = new PrivateAccessor(converter);

            EditorSelector.ResetComposedConverter();

            var view = new UserControl();
            const string fieldType = "testFieldType";

            converter.EditorFactories = new[]
                                            {
                                                new ExportFactory<UserControl, IExportAsControlForTypeMetadata>(
                                                    () => new Tuple<UserControl, Action>(view, () => { }),
                                                    new ExportAsControlForTypeAttribute(fieldType))
                                            };

            var fieldItemMock = Mock.Create<IFieldItem>(Behavior.CallOriginal);

            Mock.Arrange(() => fieldItemMock.FieldType).Returns(fieldType);
            Mock.Arrange(() => fieldItemMock.CanEdit).Returns(true);
            Mock.Arrange(() => fieldItemMock.CanView()).Returns(true);
            Mock.Arrange(() => fieldItemMock.IsInformationOnly).Returns(false);

            var returnedView = (UserControl)converter.Convert(fieldItemMock, new TypeDelegator(typeof (object)), new object(), null);

            Assert.AreEqual(view.GetType(), returnedView.GetType());
            Assert.AreSame(fieldItemMock, returnedView.DataContext);
            Assert.IsTrue(returnedView.IsEnabled);

            //check that view was cached in RegisteredViews table
            UserControl cachedView;
            var registeredViews = privateAccessor.GetField("RegisteredViews") as ConditionalWeakTable<IFieldItem, UserControl>;
            Assert.IsNotNull(registeredViews);
            Assert.IsTrue(registeredViews.TryGetValue(fieldItemMock, out cachedView));

            //remove cached view to ensure that converter will create a new one
            registeredViews.Remove(fieldItemMock);

            Mock.Arrange(() => fieldItemMock.CanEdit).Returns(false);
            Mock.Arrange(() => fieldItemMock.CanView()).Returns(false);

            returnedView = (UserControl)converter.Convert(fieldItemMock, new TypeDelegator(typeof(object)), new object(), null);

            Assert.AreEqual(view.GetType(), returnedView.GetType());
            Assert.AreSame(fieldItemMock, returnedView.DataContext);
            Assert.IsFalse(returnedView.IsEnabled);

            //now converter should return the cached view
            Mock.Arrange(() => fieldItemMock.CanEdit).Returns(true);
            Mock.Arrange(() => fieldItemMock.CanView()).Returns(true);

            var returnedCachedView = (UserControl)converter.Convert(fieldItemMock, new TypeDelegator(typeof(object)), new object(), null);

            Assert.IsTrue(ReferenceEquals(returnedView, returnedCachedView));
            Assert.AreSame(fieldItemMock, returnedCachedView.DataContext);
            Assert.IsFalse(returnedCachedView.IsEnabled);
        }
Esempio n. 2
0
        public void ChangeScreen(UserControl screen)
        {
            //foreach (var element in MainDock.Children)
            //{
            //    if (element.GetType().Name == "LoadingScreen")
            //    {
            //        MainDock.Children.Remove((UIElement) element);
            //    }
            //}

            if (screen.GetType().Name == "RemoteControlScreen")
            {
                OnRemoteCategory();
            }
            else
            {
                OnStoreCategory();
            }
            var lastElement = MainDock.Children[MainDock.Children.Count - 1];
            //if (lastElement.GetType() == screen.GetType())
            //{
            //    return;
            //}
            MainDock.Children.Remove(lastElement);
            MainDock.Children.Add(screen);

            //GC.Collect();
            //GC.WaitForPendingFinalizers();
        }
Esempio n. 3
0
        public void stateChanged(EState state)
        {
            switch (state)
            {
            case EState.Overview:
                centerView.Content = stimuliDisplayArea;
                leftView.Content   = null;
                rightView.Content  = null;
                MainCanvas.Children.Clear();
                SelectionCanvas.Children.Clear();
                if (Equals(centerView.Content.GetType(), stimuliDisplayArea.GetType()))
                {
                    ((DocumentCtrl)centerView.Content).clearText();
                }

                break;

            case EState.Streaming:
                break;

            case EState.Markup:
                rightView.Content  = markupCtrl;
                leftView.Content   = selectionCtrl;
                centerView.Content = stimuliDisplayArea;
                ((DocumentCtrl)stimuliDisplayArea).clearText();
                ((AoiCtrl)selectionCtrl).aoiList.SelectedItem       = null;
                ((AoiCtrl)selectionCtrl).recordingList.SelectedItem = null;
                ((AoiCtrl)selectionCtrl).testList.SelectedItem      = null;

                break;

            case EState.Calibrating:
                leftView.Content   = null;
                rightView.Content  = null;
                centerView.Content = calibrationCtrl;
                break;

            case EState.Ready:
                if (!Equals(ctrlwin.controller.Content.GetType(), ctrlwin.testCtrl.GetType()))
                {
                    ctrlwin.controller.Content = ctrlwin.testCtrl;
                    centerView.Content         = stimuliDisplayArea;
                }
                break;

            case EState.Setup:
                leftView.Content   = null;
                rightView.Content  = null;
                centerView.Content = null;
                break;
            }
        }
Esempio n. 4
0
        private static bool?CallOnUnloaded(UserControl lastCtrl, bool forceExit)
        {
            bool?canExit = null;

            var methodUnload = lastCtrl?.GetType().GetMethod("OnUnloaded");

            if (methodUnload != null)
            {
                canExit = (bool?)methodUnload.Invoke(lastCtrl, new object[] { forceExit });
            }

            return(canExit);
        }
Esempio n. 5
0
 public static void registerUserController(UserControl controller, string name)
 {
     if (pages.Keys.Contains(name))
     {
         throw new ArgumentException("PageName [" + name + "] is already registered!");
     }
     if (pages.Values.Contains(controller))
     {
         throw new ArgumentException("UserControl [" + controller + "] is already registered!");
     }
     pages.Add(name, controller);
     pagec.Add(controller.GetType(), controller);
 }
Esempio n. 6
0
        public void OpenWindow(UserControl userControl)
        {
            var window = _package.FindToolWindow(typeof(BaseToolWindow),
                                                      Math.Abs(userControl.GetType().ToString().GetHashCode()),
                                                      true);

            if (window == null || window.Frame == null)
            {
                throw new NotSupportedException(Resources.CanNotCreateWindow);
            }

            ((BaseToolWindow)window).SetContent(userControl);

            var windowFrame = (IVsWindowFrame)window.Frame;

            VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
        }
        /// <summary>
        /// Creates a view model for the specified view. This uses the view model type
        /// specified using a ViewModelAttribute if one is specified, and falls back to
        /// convention.
        /// The convention locates a type in the same namespace/assembly as the view, with
        /// a type name formed by adding the 'Model' or 'ViewModel' suffix to the view's type name.
        /// </summary>
        /// <param name="userControl">The control for which the view model must be created.</param>
        /// <returns>The view model instance if one could be located and instantiated.</returns>
        public static object CreateViewModel(UserControl userControl)
        {
            if (userControl == null) {
                throw new ArgumentNullException("userControl");
            }

            Type viewType = userControl.GetType();
            Type viewModelType = null;

            ViewModelAttribute vmAttribute =
                viewType.GetCustomAttributes(typeof(ViewModelAttribute), /* inherit */ true).
                         OfType<ViewModelAttribute>().FirstOrDefault();
            if (vmAttribute != null) {
                viewModelType = vmAttribute.ViewModelType;
            }

            if (viewModelType == null) {
                string viewModelTypeName = viewType.FullName + "Model";
                viewModelType = viewType.Assembly.GetType(viewModelTypeName, /* throwOnError */ false);

                if ((viewModelType == null) &&
                    (viewType.Name.EndsWith("View", StringComparison.Ordinal) == false)) {
                    viewModelTypeName = viewType.FullName + "ViewModel";
                    viewModelType = viewType.Assembly.GetType(viewModelTypeName, /* throwOnError */ false);
                }
            }

            if (viewModelType != null) {
                if (ComponentContainer.Global != null) {
                    return ComponentContainer.Global.GetObject(viewModelType);
                }

                return Activator.CreateInstance(viewModelType);
            }

            return null;
        }
		public ToastHelper(UserControl control)
		{
			_window = new ToastWindow(control);
			ToastType = control.GetType();
		}
Esempio n. 9
0
 public void navigate(UserControl fromView, UserControl destView)
 {
     ViewStack.Add((UserControl)fromView);
     View.MainWindow mainwindow = (View.MainWindow)Application.Current.MainWindow;
     string destType = destView.GetType().Name;
     if (destType == "Patients")
         mainwindow.patient_nav_item.Style = (Style)Application.Current.FindResource("ActiveMenuButton");
     else
         mainwindow.patient_nav_item.Style = (Style)Application.Current.FindResource("MenuButton");
     if (destType == "Personnel")
         mainwindow.personnel_nav_item.Style = (Style)Application.Current.FindResource("ActiveMenuButton");
     else
         mainwindow.personnel_nav_item.Style = (Style)Application.Current.FindResource("MenuButton");
     FadeOut = true;
     mainwindow.contentcontrol.Content = destView;
     FadeOut = false;
 }
Esempio n. 10
0
        public void CreateTabItem(UserControl userControl, string tabName, bool singleInstance = false,  Visibility closeButtonVisibility = Visibility.Visible,bool apendThisTabItem = true)
        {
            if (singleInstance)
            {
                if (SingleInstanceCompare == SingleInstanceCompareOption.HeaderCompare)
                {
                    string item = _tabItemRegisterList.Where(c => c == tabName).FirstOrDefault();
                    if (item == null)
                        _tabItemRegisterList.Add(tabName);
                    else
                    {
                        foreach (CloseableTabItem ti in TabControl1.Items)
                        {
                            var c = ti.Content as TabAppFormChild;
                            if (c.TitleLabel.Content.ToString() == tabName)
                            {
                                ti.IsSelected = true;
                                return;
                            }
                        }
                    }
                }
                else
                {
                    string item = _tabItemRegisterList.Where(c => c == userControl.GetType().Name).FirstOrDefault();
                    if (item == null)
                        _tabItemRegisterList.Add(userControl.GetType().Name);
                    else
                    {
                        foreach (CloseableTabItem ti in TabControl1.Items)
                        {
                            var c = ti.Content as TabAppFormChild;
                            if (c.UserControl1.Content.GetType().Name == userControl.GetType().Name)
                            {
                                ti.IsSelected = true;
                                return;
                            }
                        }
                    }
                }

            }

            var child = new TabAppFormChild();
            child.UserControl1.Content = userControl;
            child.TitleLabel.Content = tabName;

            var tabItem = new CloseableTabItem();
            tabItem.CloseButtonVisibility = closeButtonVisibility;

            var tb = new TextBlock();
            tb.Text = tabName.Length > 25 ? tabName.Substring(0, 25) + ".." : tabName;

            tb.TextTrimming = TextTrimming.CharacterEllipsis;
            tb.TextWrapping = TextWrapping.NoWrap;

            tabItem.Header = tb;
            tabItem.Content = child;
            if (apendThisTabItem)
                TabControl1.Items.Add(tabItem);
            else
                TabControl1.Items.Insert(0, tabItem);
            tabItem.IsSelected = true;
        }
Esempio n. 11
0
        private void ReLoadColumnComboBox(UserControl uc)
        {
            string controlType = uc.GetType().ToString();

            switch (controlType)
            {
                case "FastDB.Control.WhereTabRegularConditionControl":
                    WhereTabRegularConditionControl wsToCheck = (WhereTabRegularConditionControl)uc;
                    wsToCheck.cmbWhereTabLeftSideColumns.ItemsSource = GetColumnsFromAllFromTabTable();
                    wsToCheck.cmbWhereTabRightSideColumns.ItemsSource = wsToCheck.cmbWhereTabLeftSideColumns.ItemsSource;
                    break;
                case "FastDB.Control.WhereTabBetweenConditionControl":
                    WhereTabBetweenConditionControl wsbToCheck = (WhereTabBetweenConditionControl)uc;
                    wsbToCheck.cmbWhereTabBetweenColumns.ItemsSource = GetColumnsFromAllFromTabTable();
                    break;
                case "FastDB.Control.WhereTabInNotInConditionControl":
                    WhereTabInNotInConditionControl wInNotIn = (WhereTabInNotInConditionControl)uc;
                    wInNotIn.cmbWhereTabInNotInColumns.ItemsSource = GetColumnsFromAllFromTabTable();
                    break;
                case "FastDB.Control.WhereTabNullNotNullConditionControl":
                    WhereTabNullNotNullConditionControl wNullNotNull = (WhereTabNullNotNullConditionControl)uc;
                    wNullNotNull.cmbWhereTabNullNotNullColumns.ItemsSource = GetColumnsFromAllFromTabTable();
                    break;
            }
        }
Esempio n. 12
0
 public void GoTo(UserControl control)
 {
     Placeholder.Content = control;
     Context.Get<IGA>().TrackPageViewAsync(control.GetType().Name);
 }
        private void LoadControl(OSAE.OSAEObject obj)
        {
            Dispatcher.Invoke((Action)(() =>
            {
                string sStateMatch = "";

                if (obj.Type == "CONTROL USER SELECTOR")
                {
                    userSelectorControl = new UserSelector(obj, gAppName);
                  //  userSelectorControl.MouseRightButtonDown += new MouseButtonEventHandler(State_Image_MouseRightButtonDown);
                    userSelectorControl.Location.X = Double.Parse(obj.Property("X").Value);
                    userSelectorControl.Location.Y = Double.Parse(obj.Property("Y").Value);
                    userSelectorControl._ScreenLocation = gAppLocation;
                    canGUI.Children.Add(userSelectorControl);
                    Canvas.SetLeft(userSelectorControl, userSelectorControl.Location.X * gWidthRatio);
                    Canvas.SetTop(userSelectorControl, userSelectorControl.Location.Y * gHeightRatio);
                    Canvas.SetZIndex(userSelectorControl, 5);
                    controlTypes.Add(typeof(UserSelector));
                    userSelectorControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                }
                else if (obj.Type == "CONTROL SCREEN OBJECTS")
                {
                    screenObjectControl = new ScreenObjectList(obj,gCurrentScreen,gCurrentUser);
              //      screenObjectControl.MouseRightButtonDown += new MouseButtonEventHandler(State_Image_MouseRightButtonDown);
                    screenObjectControl.Location.X = Double.Parse(obj.Property("X").Value);
                    screenObjectControl.Location.Y = Double.Parse(obj.Property("Y").Value);
                    screenObjectControl._ScreenLocation = gAppLocation;
                    screenObjectControl.Visibility = System.Windows.Visibility.Hidden;

                    canGUI.Children.Add(screenObjectControl);
                    Canvas.SetLeft(screenObjectControl, screenObjectControl.Location.X * gWidthRatio);
                    Canvas.SetTop(screenObjectControl, screenObjectControl.Location.Y * gHeightRatio);
                    Canvas.SetZIndex(screenObjectControl, 5);
                    screenObjectControl.ControlWidth = screenObjectControl.Width;
                    screenObjectControl.ControlHeight = screenObjectControl.Height;
                    controlTypes.Add(typeof(ScreenObjectList));
                    screenObjectControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                }
                else if (obj.Type == "CONTROL STATE IMAGE")
                {
                    StateImage stateImageControl = new StateImage(obj, gAppName);

                    foreach (OSAE.OSAEObjectProperty p in obj.Properties)
                    {
                        try
                        {
                            if (p.Value.ToLower() == stateImageControl.CurState.ToLower())
                                sStateMatch = p.Name.Substring(0, p.Name.LastIndexOf(' '));
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error finding object ", ex);
                            return;
                        }
                    }
                    try
                    {
                        int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                        stateImageControl.MouseRightButtonDown += new MouseButtonEventHandler(State_Image_MouseRightButtonDown);
                        stateImageControl.Location.X = Double.Parse(obj.Property(sStateMatch + " X").Value);
                        stateImageControl.Location.Y = Double.Parse(obj.Property(sStateMatch + " Y").Value);
                        double dOpacity = Convert.ToDouble(stateImageControl.LightLevel) / 100.00;
                        //Opacity is new and unknow in 044
                        stateImageControl.Opacity = dOpacity;
                        canGUI.Children.Add(stateImageControl);
                        Canvas.SetLeft(stateImageControl, stateImageControl.Location.X * gWidthRatio);
                        Canvas.SetTop(stateImageControl, stateImageControl.Location.Y * gHeightRatio);
                        Canvas.SetZIndex(stateImageControl, dZ);
                        stateImageControl.Width = stateImageControl.ImageWidth * gWidthRatio;
                        stateImageControl.Height = stateImageControl.ImageHeight * gHeightRatio;
                        stateImages.Add(stateImageControl);
                        controlTypes.Add(typeof(StateImage));
                        stateImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Error updating screenObject", ex);
                        return;
                    }
                }
                else if (obj.Type == "CONTROL PROPERTY LABEL")
                {
                    if (gDebug) Log.Debug("Loading PropertyLabelControl: " + obj.Name);
                    try
                    {
                        PropertyLabel pl = new PropertyLabel(obj);
                        pl.MouseRightButtonDown += new MouseButtonEventHandler(Property_Label_MouseRightButtonDown);
                        canGUI.Children.Add(pl);
                        int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                        pl.Location.X = Double.Parse(obj.Property("X").Value);
                        pl.Location.Y = Double.Parse(obj.Property("Y").Value);
                        Canvas.SetLeft(pl, pl.Location.X * gWidthRatio);
                        Canvas.SetTop(pl, pl.Location.Y * gHeightRatio);
                        Canvas.SetZIndex(pl, dZ);
                        propLabels.Add(pl);
                        controlTypes.Add(typeof(PropertyLabel));
                        pl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Error updating PropertyLabelControl", ex);
                        return;
                    }
                }
                else if (obj.Type == "CONTROL STATIC LABEL")
                {
                    if (gDebug) Log.Debug("Loading PropertyLabelControl: " + obj.Name);
                    try
                    {

                        OSAE.UI.Controls.StaticLabel sl = new OSAE.UI.Controls.StaticLabel(obj);
                        canGUI.Children.Add(sl);
                        int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                        sl.Location.X = Double.Parse(obj.Property("X").Value);
                        sl.Location.Y = Double.Parse(obj.Property("Y").Value);
                        Canvas.SetLeft(sl, sl.Location.X * gWidthRatio);
                        Canvas.SetTop(sl, sl.Location.Y * gHeightRatio);
                        Canvas.SetZIndex(sl, dZ);
                        staticLabels.Add(sl);
                        controlTypes.Add(typeof(OSAE.UI.Controls.StaticLabel));
                        sl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (Exception ex)
                    {
                            Log.Error("Error updating PropertyLabelControl", ex);
                            return;
                    }
                }
                else if (obj.Type == "CONTROL TIMER LABEL")
                {
                    if (gDebug) Log.Debug("Loading PropertyTimerControl: " + obj.Name);
                    try
                    {

                        OSAE.UI.Controls.TimerLabel tl = new OSAE.UI.Controls.TimerLabel(obj);
                        tl.MouseRightButtonDown += new MouseButtonEventHandler(Timer_Label_MouseRightButtonDown);
                        canGUI.Children.Add(tl);
                        int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                        tl.Location.X = Double.Parse(obj.Property("X").Value);
                        tl.Location.Y = Double.Parse(obj.Property("Y").Value);
                        Canvas.SetLeft(tl, tl.Location.X * gWidthRatio);
                        Canvas.SetTop(tl, tl.Location.Y * gHeightRatio);
                        Canvas.SetZIndex(tl, dZ);
                        timerLabels.Add(tl);
                        controlTypes.Add(typeof(OSAE.UI.Controls.TimerLabel));
                        tl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Error updating PropertyTimerControl", ex);
                        return;
                    }
                }
                else if (obj.Type == "CONTROL CLICK IMAGE")
                {
                    try
                    {
                        ClickImage ClickImageControl = new ClickImage(obj, gAppName, gCurrentUser);
                        ClickImageControl.MouseRightButtonDown += new MouseButtonEventHandler(Click_Image_MouseRightButtonDown);
                        canGUI.Children.Add(ClickImageControl);
                        double dX = Convert.ToDouble(obj.Property("X").Value);
                        double dY = Convert.ToDouble(obj.Property("Y").Value);
                        int dZ = Convert.ToInt32(obj.Property("ZOrder").Value);
                        Canvas.SetLeft(ClickImageControl, dX * gWidthRatio);
                        Canvas.SetTop(ClickImageControl, dY * gHeightRatio);
                        Canvas.SetZIndex(ClickImageControl, dZ);
                        ClickImageControl.Location.X = dX;
                        ClickImageControl.Location.Y = dY;
                        ClickImageControl.Width = ClickImageControl.ImageWidth * gWidthRatio;
                        ClickImageControl.Height = ClickImageControl.ImageHeight * gHeightRatio;
                        clickImages.Add(ClickImageControl);
                        controlTypes.Add(typeof(ClickImage));
                        ClickImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (MySqlException myerror)
                    { MessageBox.Show("GUI Error Load Click Image: " + myerror.Message); }
                }
                else if (obj.Type == "CONTROL NAVIGATION IMAGE")
                {
                    try
                    {
                        NavigationImage navImageControl = new NavigationImage(obj.Property("Screen").Value, obj);
                        navImageControl.MouseLeftButtonUp += new MouseButtonEventHandler(Navigaton_Image_MouseLeftButtonUp);
                        navImageControl.MouseRightButtonDown += new MouseButtonEventHandler(Navigaton_Image_MouseRightButtonDown);
                        canGUI.Children.Add(navImageControl);
                        double dX = Convert.ToDouble(obj.Property("X").Value);
                        double dY = Convert.ToDouble(obj.Property("Y").Value);
                        int dZ = Convert.ToInt32(obj.Property("ZOrder").Value);
                        Canvas.SetLeft(navImageControl, dX * gWidthRatio);
                        Canvas.SetTop(navImageControl, dY * gHeightRatio);
                        Canvas.SetZIndex(navImageControl, dZ);
                        navImageControl.Location.X = dX;
                        navImageControl.Location.Y = dY;
                        navImageControl.Width = navImageControl.ImageWidth * gWidthRatio;
                        navImageControl.Height = navImageControl.ImageHeight * gHeightRatio;
                        navImages.Add(navImageControl);
                        controlTypes.Add(typeof(NavigationImage));
                        navImageControl.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (MySqlException myerror)
                    { MessageBox.Show("GUI Error Load Navigation Image: " + myerror.Message); }
                }
                else if (obj.Type == "CONTROL CAMERA VIEWER")
                {
                    try
                    {
                        string stream = OSAEObjectPropertyManager.GetObjectPropertyValue(obj.Property("Object Name").Value, "Stream Address").Value;
                        VideoStreamViewer vsv = new VideoStreamViewer(stream, obj, gAppName);
                        vsv.MouseRightButtonDown += new MouseButtonEventHandler(VideoStreamViewer_MouseRightButtonDown);
                        canGUI.Children.Add(vsv);
                        double dX = Convert.ToDouble(obj.Property("X").Value);
                        double dY = Convert.ToDouble(obj.Property("Y").Value);
                        int dZ = Convert.ToInt32(obj.Property("ZOrder").Value);
                        Canvas.SetLeft(vsv, dX * gWidthRatio);
                        Canvas.SetTop(vsv, dY * gHeightRatio);
                        Canvas.SetZIndex(vsv, dZ);
                        vsv.Location.X = dX;
                        vsv.Location.Y = dY;
                        cameraViewers.Add(vsv);
                        controlTypes.Add(typeof(VideoStreamViewer));
                        vsv.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (MySqlException myerror)
                    { MessageBox.Show("GUI Error Load Camera Viewer: " + myerror.Message); }
                }
                else if (obj.BaseType == "USER CONTROL")
                {
                    string sUCType = obj.Property("Control Type").Value;
                    sUCType = sUCType.Replace("USER CONTROL ", "");
                    OSAE.Types.AvailablePlugin selectedPlugin = GlobalUserControls.OSAEUserControls.AvailablePlugins.Find(sUCType);
                    selectedPlugin.Instance.InitializeMainCtrl(obj, gAppName, gCurrentUser);
                    dynamic uc = new UserControl();
                    uc = selectedPlugin.Instance.mainCtrl;
                    uc.MouseRightButtonDown += new MouseButtonEventHandler(UserControl_MouseRightButtonDown);
                    uc.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    double dX = Convert.ToDouble(obj.Property("X").Value);
                    double dY = Convert.ToDouble(obj.Property("Y").Value);
                    int dZ = Convert.ToInt32(obj.Property("ZOrder").Value);
                    Canvas.SetLeft(uc, dX * gWidthRatio);
                    Canvas.SetTop(uc, dY * gHeightRatio);
                    Canvas.SetZIndex(uc, dZ);
                    uc.setLocation(dX, dY);
                    uc.Width = uc.ControlWidth * gWidthRatio;
                    uc.Height = uc.ControlHeight * gHeightRatio;
                    canGUI.Children.Add(uc);
                    userControls.Add(uc);
                    controlTypes.Add(uc.GetType());
                }
                else if (obj.Type == "CONTROL BROWSER")
                {
                    if (gDebug) Log.Debug("Loading BrowserControl: " + obj.Name);
                    try
                    {
                        OSAE.UI.Controls.BrowserFrame bf = new OSAE.UI.Controls.BrowserFrame(obj);
                        bf.MouseRightButtonDown += new MouseButtonEventHandler(Broswer_Control_MouseRightButtonDown);
                        //OSAE.UI.Controls.StaticLabel sl = new OSAE.UI.Controls.StaticLabel(obj);
                        canGUI.Children.Add(bf);
                        int dZ = Int32.Parse(obj.Property("ZOrder").Value);
                        bf.Location.X = Double.Parse(obj.Property("X").Value);
                        bf.Location.Y = Double.Parse(obj.Property("Y").Value);
                        bf.Width = Double.Parse(obj.Property("Width").Value) * gWidthRatio;
                        bf.Height = Double.Parse(obj.Property("Height").Value) * gHeightRatio;
                        bf.ControlWidth = bf.Width;
                        bf.ControlHeight = bf.Height;
                        Canvas.SetLeft(bf, bf.Location.X * gWidthRatio);
                        Canvas.SetTop(bf, bf.Location.Y * gHeightRatio);
                        Canvas.SetZIndex(bf, dZ);
                        browserFrames.Add(bf);
                        controlTypes.Add(typeof(OSAE.UI.Controls.BrowserFrame));
                        //
                        bf.PreviewMouseMove += new MouseEventHandler(DragSource_PreviewMouseMove);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Error updating BrowserControl", ex);
                        return;
                    }
                }
            }));
        }
Esempio n. 14
0
 private string ExtractName(UserControl control)
 {
     var hostedControlAttr = control.GetType().GetCustomAttributes(true)
         .OfType<HostedControlAttribute>()
         .FirstOrDefault();
     if (hostedControlAttr == null)
     {
         return "Unknown";
     }
     return hostedControlAttr.Name;
 }
Esempio n. 15
0
        void CreateProgramIcon(string url, UserControl programUc, string processName)
        {
            var taskIcon = new Image();
            taskIcon.Source = new BitmapImage(new Uri(url));
            var imageBrush = new ImageBrush();
            imageBrush.ImageSource = taskIcon.Source;
            var taskManager = new ProgramIcon() {
                ProgramUC = new ProgramChildWindow(),
                ProcessName = processName
            };
            taskManager.ProgramUC.IsEnabled = false;
            taskManager.ProgramUC.ProcessName = processName;
            taskManager.ProgramUC.Root.Children.Add(programUc);
            taskManager.IconImage.Source = imageBrush.ImageSource;

            if(programUc.GetType() == typeof(TaskManager))
                ((TaskManager)programUc).OnProcessClosed += Desktop_OnProcessClosed;

            taskManager.OnLoadUserControl += taskManager_OnLoadUserControl;
            IconPanel.Children.Add(taskManager);
        }