Esempio n. 1
0
    static void Init()
    {
        // 打开现有的窗口,如果没有,新建一个窗口:
        MyWindow window = (MyWindow)EditorWindow.GetWindow(typeof(MyWindow));

        window.Show();
        //EditorWindow.GetWindow(typeof(MyWindow));
    }
Esempio n. 2
0
        public static void ShowBmp(Bitmap bmp)
        {
            var newwindow = new MyWindow(bmp, "Image");

            newwindow.Show();
            newwindow.Invalidate();

            Application.Run(newwindow);
        }
 public void setLoginStatus(string _status)
 {
     this.Dispatcher.Invoke(() =>
     {
         dashboard = new Dashboard.Dashboard(_status);
         loginButton.setText(_status);
         dashboard.Show();
     });
 }
Esempio n. 4
0
        public void WindowClosingDoesNothingIfAlreadyCancelled()
        {
            var model  = new Screen();
            var window = new MyWindow();

            this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model)).Returns(window);
            this.windowManager.CreateWindow(model, false);
            window.OnClosing(new CancelEventArgs(true));
        }
Esempio n. 5
0
 private void Home_Close(object sender, System.ComponentModel.CancelEventArgs e)
 {
     foreach (Window MyWindow in App.Current.Windows)
     {
         if (MyWindow != this && !(MyWindow is win_LogIn))
         {
             MyWindow.Close();
         }
     }
 }
    public static void Init(AnimatedPNGsOutput _src, RenderTexture[] frames)
    {
        // Get existing open window or if none, make a new one:
        MyWindow window = (MyWindow)EditorWindow.GetWindow(typeof(MyWindow));

        window.m_Src    = _src;
        window.m_Frames = frames;
        window.m_SW     = Stopwatch.StartNew();
        window.Show();
    }
Esempio n. 7
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (myTestWindow != null)
     {
         myTestWindow.Close();
         myTestWindow             = new MyWindow();
         myTestWindow.DockManager = dockManager;
         myTestWindow.Show(Dock.Left);
     }
 }
Esempio n. 8
0
        public MainWindow()
        {
            myTestWindow = new MyWindow();
            files        = new RecentFiles();

            PresentationTraceSources.DataBindingSource.Listeners.Add(new ConsoleTraceListener());
            PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Error;

            InitializeComponent();
        }
Esempio n. 9
0
        public void WindowStateChangedDeactivatesIfMinimized()
        {
            var model  = new Mock <IScreen>();
            var window = new MyWindow();

            this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model.Object)).Returns(window);
            this.windowManager.CreateWindow(model.Object, false);
            window.WindowState = WindowState.Minimized;
            window.OnStateChanged(EventArgs.Empty);
            model.Verify(x => x.Deactivate());
        }
Esempio n. 10
0
 static void Init()
 {
     window = ScriptableWizard.DisplayWizard<MyWindow>("Title");
     // Get existing open window or if none, make a new one:
     window.minSize = new Vector2(500, 300);
     user = User.CreateInstance("User") as User;
     UserSaveLoad userSL = UserSaveLoad.CreateInstance("UserSaveLoad") as UserSaveLoad;
     userSL.LoadData();
     user.InitUser();
     user.SetUser(userSL.myData._iUser.userID, userSL.myData._iUser.userNickName, userSL.myData._iUser.userName, userSL.myData._iUser.accessToken, userSL.myData._iUser.refreshToken);
     //Debug.LogError(user.nickname);
 }
Esempio n. 11
0
        static void Main(string[] args)
        {
            // show SpaceVIL info: version, platform, os
            Console.WriteLine(CommonService.GetSpaceVILInfo());
            // initialize SpaceVIL components
            CommonService.InitSpaceVILComponents();

            // optional: create your window and show it
            MyWindow mw = new MyWindow();

            mw.Show();
        }
Esempio n. 12
0
        /// <summary>
        /// Creates the main window.
        /// </summary>
        /// <returns>The newly created main window.</returns>
        public Window CreateWindow()
        {
            // Create a window object and set its size to the size of the
            // display.
            mainWindow        = new MyWindow();
            mainWindow.Height = SystemMetrics.ScreenHeight;
            mainWindow.Width  = SystemMetrics.ScreenWidth;

            // Set the window visibility to Visible.
            mainWindow.Visibility = Visibility.Visible;

            return(mainWindow);
        }
            public MyInkCanvas(MyWindow myWindow, MyCheckBox chkbox, int cnt)
            {
                this._myWindow = myWindow;
                this.Children.Add(new TextBlock()
                {
                    Text = cnt.ToString()
                });

                /*
                 * This exmple is based on a real leak I experienced while developing my SheetMusic Viewer
                 * https://github.com/calvinhsia/SheetMusicViewer
                 * Each instance of the InkCanvas had a rendering of a sheet music page
                 * As I played the piano reading the music, each page I turned was leaked
                 * (and sheet music PDF files consume a lot of memory), eventually
                 * causing an OutOfMemory exception.
                 * Thousands of CheckBox eventhandlers:
                 * Subscribing to the Checked method can cause a leak: the single ChkBox on the form is the Publisher of the Checked Event,
                 * and it holds a list of the subscribers in it's System.Windows.EventHandlersStore _listStore
                 * Children of "-- MyCodeToExecute.MyClass+MyCheckBox 0x21591f6c"
                 * -- MyCodeToExecute.MyClass+MyCheckBox 0x21591f6c
                 * -> _dispatcher = System.Windows.Threading.Dispatcher 0x035feb50
                 * -> _dType = System.Windows.DependencyObjectType 0x21592064
                 * -> _effectiveValues = System.Windows.EffectiveValueEntry[] 0x21599554
                 * -> MyCodeToExecute.MyClass+MyWindow 0x2158d4a0
                 * -> System.Collections.Generic.List<System.Windows.DependencyObject> 0x215922ec
                 * -> System.Windows.DeferredThemeResourceReference 0x038a8d20
                 * -> System.Windows.EventHandlersStore 0x21599548
                 * -> _entries = MS.Utility.SingleObjectMap 0x21599604
                 * -> _loneEntry = MS.Utility.FrugalObjectList<System.Windows.RoutedEventHandlerInfo> 0x215995f8
                 * -> _listStore = MS.Utility.ArrayItemList<System.Windows.RoutedEventHandlerInfo> 0x215a41d4
                 * -> _entries = System.Windows.RoutedEventHandlerInfo[] 0x3a94c858
                 * -> System.Windows.RoutedEventHandler 0x21599528
                 * -> System.Windows.RoutedEventHandler 0x21599614
                 * -> _target = MyCodeToExecute.MyClass+MyInkCanvas 0x21595aa8
                 * -> System.Windows.RoutedEventHandler 0x2159cf7c
                 * -> _target = MyCodeToExecute.MyClass+MyInkCanvas 0x215996ac
                 * -> System.Windows.RoutedEventHandler 0x215a08a8
                 * -> _target = MyCodeToExecute.MyClass+MyInkCanvas 0x2159cfd8
                 * -> System.Windows.RoutedEventHandler 0x215a41e4
                 * -> _target = MyCodeToExecute.MyClass+MyInkCanvas 0x215a0904                If the event subscriber is an empty lambda, then it doesn't leak: the eventhandler count goes up
                 *
                 */

                chkbox.Checked += (o, e) =>
                {
                    var y = arr;
                    // the lambda needs to refer to a mem var else no leak: the # ev handlers goes up, but WPF is smart: they're all the same handler
                    //   _myWindow._MyClass.logger.LogMessage("Click" + (_myWindow.numClicks++).ToString());
                };
//                chkbox.Checked += ChkboxHandler;
            }
Esempio n. 14
0
    static void Init()
    {
        // Get existing open window or if none, make a new one:
        MyWindow window = (MyWindow)EditorWindow.GetWindow(typeof(MyWindow));

        window.minSize = new Vector2(450, 500);
        window.maxSize = new Vector2(450, 500);

        Texture    icon         = AssetDatabase.LoadAssetAtPath <Texture>("Assets/UltraMare/Editor/Flags/recursos/LogoSmall.png");
        GUIContent titleContent = new GUIContent("Flag Wizard", icon);

        window.titleContent = titleContent;
        window.Show();
    }
Esempio n. 15
0
        static void Main(string[] args)
        {
            var w = new MyWindow
            {
                ProcessPath = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
                Arguments   = @"-inprivate http://images.google.com"
            };

            w.SwitchToOnlyOne(false);
            if (w.WindowRect.HasValue)
            {
                if (Clipboard.HasText)
                {
                    Thread.Sleep(8000);
                    Input.MouseClick(793, 357);
                    var task = Clipboard.GetTextAsync();
                    task.Wait();
                    var s = task.Result;
                    if (s.StartsWith("http://") || s.StartsWith("https://"))
                    {
                        Thread.Sleep(1000);
                        var keys = new[]
                        {
                            new Input.Key {
                                Up       = false,
                                ScanCode = WindowsApi.EnumLib.ScanCodeShort.CONTROL
                            },
                            new Input.Key {
                                Up       = false,
                                ScanCode = WindowsApi.EnumLib.ScanCodeShort.KEY_V
                            },
                            new Input.Key {
                                Up       = true,
                                ScanCode = WindowsApi.EnumLib.ScanCodeShort.CONTROL
                            },
                            new Input.Key
                            {
                                Up       = false,
                                ScanCode = WindowsApi.EnumLib.ScanCodeShort.RETURN
                            }
                        };
                        Input.SendKeys(keys);
                    }
                    else
                    {
                        Input.MouseClick(700, 357);
                    }
                }
            }
        }
        /// <summary>
        /// 更新属性值多语言
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void hyperlinkPropertyValueMultiLanguage_Click(object sender, RoutedEventArgs e)
        {
            dynamic property = this.dgPropertyValueQueryResult.SelectedItem as dynamic;

            UCMultiLanguageMaintain item = new UCMultiLanguageMaintain(property.SysNo, "PIM_PropertyValue");

            item.Dialog = MyWindow.ShowDialog("更新属性值多语言", item, (s, args) =>
            {
                if (args.DialogResult == Newegg.Oversea.Silverlight.Controls.Components.DialogResultType.OK)
                {
                    this.dgPropertyValueQueryResult.Bind();
                }
            }, new Size(750, 600));
        }
Esempio n. 17
0
        /// <summary>
        /// Create a window with button focus.
        /// </summary>
        /// <returns></returns>
        public Window CreateWindow()
        {
            /// Create a window and set its size to the size of the display.
            mainWindow        = new MyWindow();
            mainWindow.Height = SystemMetrics.ScreenHeight;
            mainWindow.Width  = SystemMetrics.ScreenWidth;

            // Set the window visibility to visible.
            mainWindow.Visibility = Visibility.Visible;

            // Attach the button focus to the window.
            Buttons.Focus(mainWindow);

            return(mainWindow);
        }
Esempio n. 18
0
        private void StartApplication()
        {
            Thread windowThread = new Thread(new ThreadStart(() => {
                window = new MyWindow(this);
                window.Show();
                System.Windows.Threading.Dispatcher.Run();
            }));

            windowThread.SetApartmentState(ApartmentState.STA);
            windowThread.Start();
            SetUpInterruptAndEndListener();
            Thread.Sleep(2500);
            GetRepetitoires();
            waitForStartThread = new Thread(AskForStart);
            waitForStartThread.Start();
        }
Esempio n. 19
0
        public void OnJobSave()
        {
            if (!Editing)
            {
                MyJob      = new Job();
                MyJob.Name = JobName;
                MyJob.DocumentsIncluded = new List <string>();
                MyCraft.Jobs.Add(MyJob);
                MyMainViewModel.Jobs.Add(MyJob);
            }
            else
            {
                MyJob.Name = JobName;
            }

            MyWindow.Close();
        }
Esempio n. 20
0
        private MyWindow CreateWindow()
        {
            // Create a window object and set its size to the
            // size of the display.
            mainWindow = new MyWindow();       
            mainWindow.Height = _height;
            mainWindow.Width = _width;

            Text t = new Text(_font, "Presentaion Tests !");
            t.VerticalAlignment = VerticalAlignment.Center;
            t.HorizontalAlignment = HorizontalAlignment.Center;         
            mainWindow.Child = t;
            // Set the window visibility to visible.
            mainWindow.Visibility = Visibility.Visible;
            
            return mainWindow;
        }
Esempio n. 21
0
        private MyWindow CreateWindow()
        {
            // Create a window object and set its size to the
            // size of the display.
            mainWindow        = new MyWindow();
            mainWindow.Height = _height;
            mainWindow.Width  = _width;

            Text t = new Text(_font, "Presentaion Tests !");

            t.VerticalAlignment   = VerticalAlignment.Center;
            t.HorizontalAlignment = HorizontalAlignment.Center;
            mainWindow.Child      = t;
            // Set the window visibility to visible.
            mainWindow.Visibility = Visibility.Visible;

            return(mainWindow);
        }
Esempio n. 22
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="title"></param>
        /// <param name="view"></param>
        /// <param name="onDialogCloseCallBack"></param>
        public static void ShowDialogForm(string title, UserControl view, object item = null, MyWindow.AfterCloseDelegate afterClose = null)
        {
            try
            {
                var window = new MyWindow(item, afterClose, false);
                window.lblTitle.Content = title;
                window.pnlBody.Width    = view.Width;
                window.pnlBody.Height   = view.Height;
                window.pnlBody.Children.Add(view);
                window.pnlHead.Width = view.Width;

                window.Show();
            }
            catch
            {
                return;
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Creates the main window.
        /// </summary>
        /// <returns>The newly created main window.</returns>
        public Window CreateWindow()
        {
            // Create a window object and set its size to the size of the 
            // display.
            mainWindow = new MyWindow();
            mainWindow.Height = SystemMetrics.ScreenHeight;
            mainWindow.Width = SystemMetrics.ScreenWidth;

            // Set the window visibility to Visible.
            mainWindow.Visibility = Visibility.Visible;

            return mainWindow;
        }
Esempio n. 24
0
    override protected void CreateChildren()
    {
        base.CreateChildren();

        #region Controls

        Toolbar toolbar = new Toolbar();
        AddChild(toolbar);

        #region Alert

        Button btnAlert = new Button
        {
            Text = "Alert",
            FocusEnabled = false,
            SkinClass = typeof(ImageButtonSkin),
            Icon = ImageLoader.Instance.Load("Icons/comment")
        };
        btnAlert.Click += delegate
        {
            Alert.Show("Info", "This is the example alert.", AlertButtonFlag.Ok,
                new AlertOption(AlertOptionType.HeaderIcon, Resources.Load<Texture>("Icons/information")),
                new AlertOption(AlertOptionType.Icon, Resources.Load<Texture>("Icons/star_big")));
        };
        toolbar.AddContentChild(btnAlert);

        #endregion

        #region Window

        Button btnWindow = new Button
        {
            Text = "New window",
            FocusEnabled = false,
            SkinClass = typeof(ImageButtonSkin),
            Icon = ImageLoader.Instance.Load("Icons/comment")
        };
        btnWindow.Click += delegate
        {
            _count++;
            var window = new MyWindow
            {
                Title = "The Window " + _count,
                Id = "window_" + _count,
                SkinClass = typeof(WindowSkin2),
                Icon = ImageLoader.Instance.Load("Icons/balloon_32"),
                Width = 400,
                Height = 600
            };

            window.SetStyle("addedEffect", _windowShow);
            window.Plugins.Add(new Resizable { ShowOverlay = false });
            window.AddEventListener(CloseEvent.CLOSE, delegate
            {
                PopupManager.Instance.RemovePopup(window);
            });
            PopupManager.Instance.AddPopup(window, false);
            PopupManager.Instance.CenterPopUp(window);
        };
        toolbar.AddContentChild(btnWindow);

        #endregion

        #endregion

        #region Scroller

        Scroller scroller = new Scroller
        {
            SkinClass = typeof (ScrollerSkin2),
            PercentWidth = 100, PercentHeight = 100
        };
        //scroller.SetStyle("horizontalScrollPolicy", ScrollPolicy.On);
        //scroller.SetStyle("verticalScrollPolicy", ScrollPolicy.On);
        AddChild(scroller);

        Group viewport = new Group
        {
            Layout = new VerticalLayout
            {
                HorizontalAlign = HorizontalAlign.Left,
                PaddingLeft = 10,
                PaddingRight = 10,
                PaddingTop = 10,
                PaddingBottom = 10,
                Gap = 10
            }
        };
        scroller.Viewport = viewport;

        #endregion
        
        #region Horizontal Scrollbars

        viewport.AddChild(new HScrollBar { SkinClass = typeof(HScrollBarSkin3), PercentWidth = 100, MinWidth = 300, Maximum = 300, PageSize = 100 });
        viewport.AddChild(new HScrollBar { SkinClass = typeof(HScrollBarSkin3), PercentWidth = 50, Maximum = 500, Value = 200, PageSize = 100 });
        viewport.AddChild(new HScrollBar { SkinClass = typeof(HScrollBarSkin2), MinWidth = 600, Maximum = 1000, PageSize = 100 });
        viewport.AddChild(new HScrollBar { SkinClass = typeof(HScrollBarSkin3), MinWidth = 700, Maximum = 300, PageSize = 100 });
        viewport.AddChild(new HScrollBar { PercentWidth = 100, MinWidth = 600, SkinClass = typeof(HScrollBarSkin3), Maximum = 1000, PageSize = 100 });

        #endregion

        #region HGroup

        HGroup hGroup = new HGroup { /*PercentWidth = 100, */Gap = 10 };
        viewport.AddChild(hGroup);

        #endregion

        #region Vertical scrollbars

        VScrollBar vScrollBar = new VScrollBar { PercentHeight = 100, Maximum = 300 };
        vScrollBar.Change += delegate(Event e) { Debug.Log("Change: " + e); };
        hGroup.AddChild(vScrollBar);

        hGroup.AddChild(new VScrollBar { PercentHeight = 100, Maximum = 400, PageSize = 100 });
        hGroup.AddChild(new VScrollBar { SkinClass = typeof(VScrollBarSkin2), PercentHeight = 100, Maximum = 1000, PageSize = 100 });
        hGroup.AddChild(new VScrollBar { SkinClass = typeof(VScrollBarSkin2), Height = 400, Maximum = 400, PageSize = 100 });
        hGroup.AddChild(new VScrollBar { SkinClass = typeof(VScrollBarSkin3), PercentHeight = 100, Maximum = 200, PageSize = 100 });
        hGroup.AddChild(new VScrollBar { SkinClass = typeof(VScrollBarSkin3), Height = 400, Maximum = 300, PageSize = 100 });

        #endregion

        #region Panels

        //hGroup.AddChild(new Spacer { PercentWidth = 50 });

        Panel panel = new MyPanel
        {
            Width = 360,
            Height = 600,
            Icon = ImageLoader.Instance.Load("Icons/shape_square_add"),
            Title = "First panel",
            StyleName = "default"
        };
        hGroup.AddChild(panel);

        panel = new MyPanel2
        {
            MaxWidth = 500,
            Height = 600,
            SkinClass = typeof (PanelSkin2),
            Icon = ImageLoader.Instance.Load("Icons/page_white_text"),
            Title = "Second panel"
        };
        panel.SetStyle("titleColor", 0xffff00);
        hGroup.AddChild(panel);

        //hGroup.AddChild(new Spacer { PercentWidth = 50 });

        #endregion

        #region Vertical sliders

        hGroup.AddChild(new VSlider { PercentHeight = 100 });
        hGroup.AddChild(new VSlider { Width = 30, Height = 400, SkinClass = typeof(VSliderSkin2) });
        hGroup.AddChild(new VSlider { Width = 30, Height = 400, SkinClass = typeof(VSliderSkin2), Enabled = false });
        hGroup.AddChild(new VSlider { Width = 50, Height = 400, SkinClass = typeof(VSliderSkin2) });
        hGroup.AddChild(new VSlider { Width = 80, Height = 400, SkinClass = typeof(VSliderSkin3) });
        hGroup.AddChild(new VSlider { Width = 80, PercentHeight = 100, Maximum = 1000, SkinClass = typeof(VSliderSkin3) });

        #endregion

        #region Horizontal sliders

        viewport.AddChild(new HSlider { Maximum = 400, PercentWidth = 100 });
        viewport.AddChild(new HSlider { Width = 400, Maximum = 400, Height = 30, SkinClass = typeof(HSliderSkin2) });
        viewport.AddChild(new HSlider { Width = 400, Maximum = 400, Height = 50, SkinClass = typeof(HSliderSkin2) });
        viewport.AddChild(new HSlider { PercentWidth = 50, Height = 80, SkinClass = typeof(HSliderSkin3) });
        viewport.AddChild(new HSlider { PercentWidth = 100, Maximum = 1000, Height = 80, SkinClass = typeof(HSliderSkin3) });

        #endregion

    }
Esempio n. 25
0
    private MyWindow GetWindow()
    {
        /*DeferManager.Instance.Defer(delegate
        {
            var window = new MyWindow
            {
                Title = "The Window " + _count,
                Id = "window_" + _count,
                SkinClass = typeof(WindowSkin2),
                Icon = ImageLoader.Instance.Load("Icons/balloon_32"),
                Width = 400,
                Height = 600,
                Visible = false,
                IncludeInLayout = false
            };

            /*window.SetStyle("addedEffect", _windowShow);
            window.Plugins.Add(new Resizable { ShowOverlay = false });
            window.AddEventListener(CloseEvent.CLOSE, delegate { PopupManager.Instance.RemovePopup(window); });#1#

            PopupManagerStage.Instance.AddChild(window);

            _window = window;

        }, 5);*/

        if (null != _window)
        {
            PopupManagerStage.Instance.RemoveChild(_window);
            var window = _window;
            _window = null;
            return window;
        }
        PrepareWindow();
        return _window;
    }
Esempio n. 26
0
        /// <summary>
        /// Creates a window that has button focus.
        /// </summary>
        /// <returns></returns>
        public Window CreateWindow()
        {
            // Create a window object and set its size to the size of the 
            // display.
            mainWindow = new MyWindow();
            mainWindow.Height = SystemMetrics.ScreenHeight;
            mainWindow.Width = SystemMetrics.ScreenWidth;

            // Connect the button handler to all of the buttons.
            mainWindow.AddHandler(Buttons.ButtonUpEvent,
                new RoutedEventHandler(OnButtonUp), false);

            // Set the window visibility to Visible.
            mainWindow.Visibility = Visibility.Visible;

            // Attach the button focus to the window.
            Buttons.Focus(mainWindow);

            return mainWindow;
        }
Esempio n. 27
0
        public void CloseItemDoesNothingIfCanCloseReturnsFalse()
        {
            var model = new Mock<IScreen>();
            var window = new MyWindow();
            this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model.Object)).Returns(window);
            object parent = null;
            model.SetupSet(x => x.Parent = It.IsAny<object>()).Callback((object x) => parent = x);
            this.windowManager.CreateWindow(model.Object, false);

            model.Setup(x => x.CanCloseAsync()).Returns(Task.Delay(10).ContinueWith(t => false));
            ((IChildDelegate)parent).CloseItem(model.Object);
        }
Esempio n. 28
0
 public void WindowClosingCancelsIfCanCloseAsyncReturnsAsynchronousFalse()
 {
     var model = new Mock<IScreen>();
     var window = new MyWindow();
     this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model.Object)).Returns(window);
     this.windowManager.CreateWindow(model.Object, false);
     model.Setup(x => x.CanCloseAsync()).Returns(Task.Delay(10).ContinueWith(t => false));
     var ea = new CancelEventArgs();
     window.OnClosing(ea);
     Assert.True(ea.Cancel);
 }
Esempio n. 29
0
 public void WindowClosingDoesNothingIfAlreadyCancelled()
 {
     var model = new Screen();
     var window = new MyWindow();
     this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model)).Returns(window);
     this.windowManager.CreateWindow(model, false);
     window.OnClosing(new CancelEventArgs(true));
 }
Esempio n. 30
0
	public void HandleClickFileSystem(int EventIndex) {
		if (EventIndex >= 0 && EventIndex < MyEvents.Count) {
			GameEvent MyEvent = MyEvents [EventIndex];
			string MyFilePath = FileLocation + "\\" + MyEvent.EventText;
			if (!IsFilePathAFolder (MyFilePath)) {
				FileLocation = MyFilePath;
				AddFileSystem ();
			} else {	// if a file
				string FileExtension = Path.GetExtension (MyEvent.EventText);
				switch (FileExtension) {
				case (".png"):
					// open it in a window heree
					TestTexture = new Texture2D (1, 1);
					TestTexture.LoadImage (File.ReadAllBytes (MyFilePath));	// auto resizes it!
					TestWindow = new MyWindow (TestTexture);
					TestWindow.Name = MyEvent.EventText;
					// maybe create a max, and use scrollbars and mask for the images
					GetManager.GetGuiCreator ().CreateWindow (TestWindow, GetManager.GetGuiCreator ().MyWindows.Count);
					TestWindow.WindowReference.transform.GetChild (1).gameObject.AddComponent<TextureEditorHandler> ();
					break;
				case (".vmd"):	// voxel file
					// open it in a window heree
					GameObject.Find ("MyModelEditorManager").GetComponent<ModelEditorManager> ().LoadModel (MyEvent.EventText);	// or maybe create a new window linked to that model?
					// maybe create a max, and use scrollbars and mask for the images
					//GetManager.GetGuiCreator().CreateWindow(TestWindow, GetManager.GetGuiCreator().MyWindows.Count);
					break;
					
				case (".chk"):	// chunk file
					List<string> FolderNames = new List<string> ();
					int NameCount1 = 0;
					
					for (int i = 0; i < FileLocation.Length; i++) {
						if (FileLocation [i] == '\\') {
							FolderNames.Add (FileLocation.Substring (NameCount1, i - NameCount1));
							NameCount1 = i + 1;
						}
					}
					string NewGameName = "";
					if (FolderNames.Count >= 2)
						NewGameName = FolderNames [FolderNames.Count - 2];
					if (NewGameName != "") {
						GetManager.GetGameManager ().GameName = NewGameName;
						GetManager.GetGameManager ().PlayAdventureGame ();
					}
					// open it in a window heree
					//GameObject.Find ("MyModelEditorManager").GetComponent<ModelEditorManager>().LoadModel(MyEvent.EventText);
					// maybe create a max, and use scrollbars and mask for the images
					//GetManager.GetGuiCreator().CreateWindow(TestWindow, GetManager.GetGuiCreator().MyWindows.Count);
					break;
				}
			}
		}
	}
Esempio n. 31
0
        public Window CreateWindow()
        {
            // Create a window object and set its size to the
            // size of the display.
            mainWindow = new MyWindow();
            mainWindow.Height = SystemMetrics.ScreenHeight;
            mainWindow.Width = SystemMetrics.ScreenWidth;

            mainWindow.AddHandler(Buttons.ButtonUpEvent,
                new RoutedEventHandler(OnButtonUp), false);

            // Set the window visibility to visible.
            mainWindow.Visibility = Visibility.Visible;

            // Attach the button focus to the window.
            Buttons.Focus(mainWindow);

            TimeService.SystemTimeChanged += new SystemTimeChangedEventHandler(TimeService_SystemTimeChanged);
            TimeService.TimeSyncFailed += new TimeSyncFailedEventHandler(TimeService_TimeSyncFailed);

            mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                                        new DispatcherOperationCallback(CleanWindow), null);

            return mainWindow;
        }
Esempio n. 32
0
    MyWindow MakeTests()
    {
        var window = new MyWindow(ButtonSprite, "Tests", new Rect(0, 0, kMenuWidth, kMenuHeight));
        var scroll = new MyScrollBar(ButtonSprite);

        var scrollView = new MyList(ButtonSprite, new Rect(78, 0, 200, 241));
        scrollView.SetAnchor(new Vector2(0.5f, 0), new Vector2(1, 1));
        scrollView.Element.GetComponent<RectTransform>().offsetMin = new Vector2(0, 0);
        scrollView.Element.GetComponent<RectTransform>().offsetMax = new Vector2(-20, 0);

        folder = stateMenu.StateFolder[stateMenu.CurrentAssembly][stateMenu.CurrentLevel];
        var data = new LoadingData
        {
            AssemblyName = stateMenu.CurrentAssembly,
            Level = stateMenu.CurrentLevel
        };

        foreach (var e in folder.GetChildrenTests())
        {
            if (e.State != 0 && TestDispatcher.LastTestExecution.ContainsKey(e.NameTest))
                TestDispatcher.LastTestExecution[e.NameTest] = e.State == 1;
            else if (e.State != 0 && !TestDispatcher.LastTestExecution.ContainsKey(e.NameTest))
                TestDispatcher.LastTestExecution.Add(e.NameTest, e.State == 1);
        }

        var buttonTest = TestButton(folder, ButtonSprite, data, backgroundStateTest);

        folderIsLoad = true;
        var scrollR = scrollView.Element.GetComponent<ScrollRect>();
        scrollR.scrollSensitivity = 10;
        scrollR.verticalScrollbar = scroll.Element.GetComponent<Scrollbar>();
        scrollView.Element.name = "ScrollView";
        window.AddElement(scrollView);
        buttonTest.Element.name = "HeadButton";
        scrollView.MainElement.AddElement(buttonTest);
        scrollView.MainElement.Element.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;

        window.AddElement(scroll);

        return window;
    }
Esempio n. 33
0
    void Start()
    {
        if (!serverIsRunned)
        {
            Server();
            serverIsRunned = true;
        }

        mainCanvas = new MyCanvas(new Vector2(Screen.width, Screen.height));
        MakeState();
        windowTests = MakeTests();
        windowTests.SetActive(stateMenu.IsOpenTestsWindow);
        var buttonWindowTests = new MyButton(() => windowTests.SetActive(!windowTests.isOpen), ButtonSprite, new Rect(0, 0, 64, 48), "Tests");
        var rectB = buttonWindowTests.Element.GetComponent<RectTransform>();
        var inputField = new MyInputField("Input", ButtonSprite, new Rect(0, 0, 160, 25));
        buttonWindowTests.SetAnchor(new Vector2(0, 1), new Vector2(0, 1));

        var buttonLog = new MyButton(
            () => Dispatcher.AddRunner(new LogRunner(inputField.Element.GetComponent<InputField>().text)),
            ButtonSprite,
            new Rect(0, 0, 64, 48),
            "Log play");

        var rectLog = buttonLog.Element.GetComponent<RectTransform>();
        buttonLog.SetAnchor(0, 0, 0, 0);
        rectLog.anchoredPosition = new Vector2(300, 40);

        rectB.offsetMin = new Vector2(100, -200);
        UIElement.SetSize(rectB, new Vector2(120, 30));
        var buttonTutorial = new MyButton(
            () => Dispatcher.AddRunner(new TutorialRunner(new LoadingData { AssemblyName = "RoboMovies", Level = "Test" })),
            ButtonSprite,
            new Rect(0, 00, 120, 48),
            "Tutorial");
        buttonTutorial.SetAnchor(new Vector2(0, 1), new Vector2(0, 1));

        rectB = buttonTutorial.Element.GetComponent<RectTransform>();
        rectB.offsetMin = new Vector2(100, -300);
        UIElement.SetSize(rectB, new Vector2(120, 30));

        dropDownListAssembly = Instantiate(DropDownList);
        dropDownListAssembly.name = "BambaLeilo";
        dropDownListAssembly.transform.localPosition = new Vector3(0, 0);
        var dropDown = dropDownListAssembly.GetComponent<Dropdown>();
        dropDown.GetComponent<RectTransform>().position = new Vector3(0, 0, 0);
        dropDown.options = new List<Dropdown.OptionData>();
        foreach (var e in Dispatcher.Loader.Levels.Keys)
            dropDown.options.Add(new Dropdown.OptionData(e));

        for (var i = 0; i < dropDown.options.Count; i++)
            if (dropDown.options[i].text == stateMenu.CurrentAssembly)
                dropDown.value = i;

        dropDownListLevel = Instantiate(DropDownList);
        dropDownListLevel.name = "BambaLeiloLevel";
        dropDownListLevel.transform.localPosition = new Vector3(0, 0);
        var dropDownList = dropDownListLevel.GetComponent<Dropdown>();
        dropDownList.GetComponent<RectTransform>().position = new Vector3(0, 0, 0);
        dropDownList.options = new List<Dropdown.OptionData>();
        foreach (var e in Dispatcher.Loader.Levels[stateMenu.CurrentAssembly].Keys)
            dropDownList.options.Add(new Dropdown.OptionData(e));

        for (var i = 0; i < dropDownList.options.Count; i++)
            if (dropDownList.options[i].text == stateMenu.CurrentLevel)
            {
                dropDownList.value = i;
                dropDownList.options[i] = new Dropdown.OptionData(stateMenu.CurrentLevel);
            }

        var backGround = new MyImage(menuBackground, new Rect(0, 0, menuBackground.textureRect.width, menuBackground.textureRect.height));

        mainCanvas.AddElement(backGround);
        mainCanvas.AddElement(inputField);
        mainCanvas.AddElement(windowTests.Head);
        mainCanvas.AddElement(buttonWindowTests);
        mainCanvas.AddElement(buttonTutorial);
        mainCanvas.AddElement(buttonLog);
        dropDownListLevel.transform.SetParent(mainCanvas.Element.transform);
        dropDown.transform.SetParent(mainCanvas.Element.transform);

        var rectDrop = dropDownListAssembly.GetComponent<RectTransform>();
        rectDrop.anchorMin = new Vector2(0, 1);
        rectDrop.anchorMax = new Vector2(0, 1);
        rectDrop.anchoredPosition = new Vector3(100, -40, 0);

        rectDrop = dropDownListLevel.GetComponent<RectTransform>();
        rectDrop.anchorMin = new Vector2(0, 1);
        rectDrop.anchorMax = new Vector2(0, 1);
        rectDrop.anchoredPosition = new Vector3(300, -40, 0);

        rectDrop = inputField.Element.GetComponent<RectTransform>();
        inputField.SetAnchor(0, 0, 0, 0);
        rectDrop.anchoredPosition = new Vector3(100, 40, 0);
    }
Esempio n. 34
0
	// input window - things like text, or a yes or no, or a quest
	// stops the player from inputting anything else
	// used for urgent matters
	
	public void CreateInputWindow(string InputString) {
		if (ChatWindowIndex == -1) {
			DisableAllWindows ();
			MyWindow NewChatWindow = new MyWindow ();
			NewChatWindow.Size = new Vector3 (250, 75);
			NewChatWindow.Position.x = -125;
			NewChatWindow.Position.y = 375;
			NewChatWindow.HasDragZone = true;
			NewChatWindow.HasCloseButton = false;
			NewChatWindow.IsInputText = true;
			NewChatWindow.Name = InputString;
			MyWindows.Add (NewChatWindow);
			ChatWindowIndex = MyWindows.Count - 1;
			CreateWindow (NewChatWindow, MyWindows.Count - 1);
		}
	}
Esempio n. 35
0
	public void UpdateText(string NewText, int PositionX, int PositionY, MyWindow NewWindow) {
		int Index = PositionY + PositionX * ColumnsMax;
		NewWindow.CellsReference[Index].GetComponent<Text>().text = NewText;
	}
Esempio n. 36
0
    void Update()
    {
        Dispatcher.IntroductionTick();
        var d = dropDownListAssembly.GetComponent<Dropdown>();
        if (stateMenu.CurrentAssembly != d.options[d.value].text)
        {
            stateMenu.CurrentAssembly = d.options[d.value].text;
            var dropListLevel = dropDownListLevel.GetComponent<Dropdown>();
            dropListLevel.options = new List<Dropdown.OptionData>();
            foreach(var e in Dispatcher.Loader.Levels[stateMenu.CurrentAssembly].Keys)
                dropListLevel.options.Add(new Dropdown.OptionData(e));
            dropListLevel.value = 0;
            stateMenu.CurrentLevel = dropListLevel.options[dropListLevel.value].text;
            Destroy(windowTests.Head.Element);
            windowTests = MakeTests();
            mainCanvas.AddElement(windowTests.Head);

        }
        d = dropDownListLevel.GetComponent<Dropdown>();
        if (stateMenu.CurrentLevel != d.options[d.value].text)
        {
            stateMenu.CurrentLevel = d.options[d.value].text;
            Destroy(windowTests.Head.Element);
            windowTests = MakeTests();
            mainCanvas.AddElement(windowTests.Head);
        }
    }
Esempio n. 37
0
        /// <summary>
        /// Create a window with button focus.
        /// </summary>
        /// <returns></returns>
        public Window CreateWindow()
        {
            /// Create a window and set its size to the size of the display.
            mainWindow = new MyWindow();
            mainWindow.Height = SystemMetrics.ScreenHeight;
            mainWindow.Width = SystemMetrics.ScreenWidth;

            // Set the window visibility to visible.
            mainWindow.Visibility = Visibility.Visible;

            // Attach the button focus to the window.
            Buttons.Focus(mainWindow);

            return mainWindow;
        }
Esempio n. 38
0
 public void WindowStateChangedDeactivatesIfMinimized()
 {
     var model = new Mock<IScreen>();
     var window = new MyWindow();
     this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model.Object)).Returns(window);
     this.windowManager.CreateWindow(model.Object, false);
     window.WindowState = WindowState.Minimized;
     window.OnStateChanged(EventArgs.Empty);
     model.Verify(x => x.Deactivate());
 }
Esempio n. 39
0
    override protected void CreateChildren()
    {
        base.CreateChildren();

        #region Controls

        Toolbar toolbar = new Toolbar();
        AddChild(toolbar);

        Button btnAlert = new Button
        {
            Text = "Alert",
            FocusEnabled = false,
            SkinClass = typeof(ImageButtonSkin),
            Icon = ImageLoader.Instance.Load("Icons/comment")
        };
        btnAlert.Click += delegate
        {
            Alert.DefaultSkin = null;
            Alert.Show(
                "Title", "Message", AlertButtonFlag.Ok,
                new AlertOption(AlertOptionType.Icon, Resources.Load<Texture>("edriven_gui")),
                new AlertOption(AlertOptionType.HeaderIcon, Resources.Load<Texture>("Icons/accept"))
            );
        };
        toolbar.AddContentChild(btnAlert);

        btnAlert = new Button
        {
            Text = "Alert (skin 2)",
            FocusEnabled = false,
            SkinClass = typeof(ImageButtonSkin),
            Icon = ImageLoader.Instance.Load("Icons/comment")
        };
        btnAlert.Click += delegate
        {
            Alert.DefaultSkin = typeof(AlertSkin2);
            Alert.Show(
                "Title", "Message", AlertButtonFlag.Ok,
                new AlertOption(AlertOptionType.Icon, Resources.Load<Texture>("Icons/star_big")),
                new AlertOption(AlertOptionType.HeaderIcon, Resources.Load<Texture>("Icons/accept"))
            );
        };
        toolbar.AddContentChild(btnAlert);

        btnAlert = new Button
        {
            Text = "Alert (skin 3)",
            FocusEnabled = false,
            SkinClass = typeof(ImageButtonSkin),
            Icon = ImageLoader.Instance.Load("Icons/comment")
        };
        btnAlert.Click += delegate
        {
            Alert.DefaultSkin = typeof(AlertSkin3);
            Alert.Show(
                "Title", "Message", AlertButtonFlag.Ok,
                new AlertOption(AlertOptionType.Icon, Resources.Load<Texture>("Icons/star_big")),
                new AlertOption(AlertOptionType.HeaderIcon, Resources.Load<Texture>("Icons/accept"))
            );
        };
        toolbar.AddContentChild(btnAlert);

        Button btnWindow = new Button
        {
            Text = "New window",
            FocusEnabled = false,
            SkinClass = typeof(ImageButtonSkin),
            Icon = ImageLoader.Instance.Load("Icons/comment")
        };
        btnWindow.Click += delegate
        {
            _count++;

            var window = new MyWindow
            {
                Title = "The Window " + _count,
                Id = "window_" + _count,
                SkinClass = typeof(WindowSkin2),
                Icon = ImageLoader.Instance.Load("Icons/balloon_32"),
                Width = 500,
                Height = 600
            };

            window.SetStyle("addedEffect", _windowShow);
            window.Plugins.Add(new Resizable { ShowOverlay = false });
            window.AddEventListener(CloseEvent.CLOSE, delegate
            {
                PopupManager.Instance.RemovePopup(window);
            });

            PopupManager.Instance.AddPopup(window, false);
            PopupManager.Instance.CenterPopUp(window);
        };
        toolbar.AddContentChild(btnWindow);

        #endregion

        Scroller scroller = new Scroller
        {
            SkinClass = typeof(ScrollerSkin2),
            PercentWidth = 100,
            PercentHeight = 100
        };
        AddChild(scroller);

        Group viewport = new Group
                             {
                                 Layout = new VerticalLayout
                                 {
                                     HorizontalAlign = HorizontalAlign.Left,
                                     PaddingLeft = 10, PaddingRight = 10, PaddingTop = 10, PaddingBottom = 10,
                                     Gap = 10
                                 }
                             };
        scroller.Viewport = viewport;
    }
Esempio n. 40
0
 public void WindowClosingDoesNotCancelIfCanCloseAsyncReturnsSynchronousTrue()
 {
     var model = new Mock<IScreen>();
     var window = new MyWindow();
     this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model.Object)).Returns(window);
     this.windowManager.CreateWindow(model.Object, false);
     model.Setup(x => x.CanCloseAsync()).Returns(Task.FromResult(true));
     var ea = new CancelEventArgs();
     window.OnClosing(ea);
     Assert.False(ea.Cancel);
 }
Esempio n. 41
0
    public void PrepareWindow()
    {
        _count++;

        Debug.Log("PrepareWindow");
        var window = new MyWindow
        {
            Title = "The Window " + _count,
            Id = "window_" + _count,
            SkinClass = typeof(WindowSkin2),
            Icon = ImageLoader.Instance.Load("Icons/balloon_32"),
            Width = 400,
            Height = 600,
            Visible = false,
            IncludeInLayout = false
        };
        window.Plugins.Add(new Resizable { ShowOverlay = false });
        PopupManagerStage.Instance.AddChild(window);
        _window = window;
    }
Esempio n. 42
0
 public void WindowClosingCancelsIfCanCloseAsyncReturnsAsynchronous()
 {
     var model = new Mock<IScreen>();
     var window = new MyWindow();
     this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model.Object)).Returns(window);
     this.windowManager.CreateWindow(model.Object, false);
     var tcs = new TaskCompletionSource<bool>();
     model.Setup(x => x.CanCloseAsync()).Returns(tcs.Task);
     var ea = new CancelEventArgs();
     window.OnClosing(ea);
     Assert.True(ea.Cancel);
 }
Esempio n. 43
0
        public void WindowClosingClosesWindowIfCanCloseAsyncCompletesTrue()
        {
            var model = new Mock<IMyScreen>();
            var window = new MyWindow();
            this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model.Object)).Returns(window);
            this.windowManager.CreateWindow(model.Object, false);
            var tcs = new TaskCompletionSource<bool>();
            model.Setup(x => x.CanCloseAsync()).Returns(tcs.Task);
            window.OnClosing(new CancelEventArgs());
            model.Verify(x => x.Close(), Times.Never);
            tcs.SetResult(true);
            model.Verify(x => x.Close(), Times.Once);

            Assert.True(window.OnClosedCalled);

            // Check it didn't call WindowClosing again - just the first time
            model.Verify(x => x.CanCloseAsync(), Times.Once);
        }
Esempio n. 44
0
 public void CloseItemDoesNothingIfItemIsWrong()
 {
     var model = new Screen();
     var window = new MyWindow();
     this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model)).Returns(window);
     this.windowManager.CreateWindow(model, false);
     ((IChildDelegate)model.Parent).CloseItem(new object());
 }
Esempio n. 45
0
	public GameObject CreateWindow(MyWindow NewWindow, int WindowIndex) {
		NewWindow.Position = new Vector3 (-	NewWindow.Position.x, NewWindow.Position.y, NewWindow.Position.z);
		NewWindow.Position -= new Vector3 (NewWindow.Size.x / 2f, -NewWindow.Size.y / 2f, 0);

		NewWindow.WindowReference =	(GameObject) Instantiate (PanelPrefab, new Vector3 (), Quaternion.identity);
		NewWindow.WindowReference.GetComponent<ActiveStateToggler> ().IsDestroyOnClose = NewWindow.IsDestroyOnClose;
		SetGuiSettings (NewWindow.WindowReference, NewWindow.Position, NewWindow.Size);
		NewWindow.WindowReference.GetComponent<RawImage> ().color = NewWindow.WindowColor;
		NewWindow.WindowReference.GetComponent<RectTransform> ().anchorMin = new Vector2 (0, 0);
		NewWindow.WindowReference.GetComponent<RectTransform> ().anchorMax = new Vector2 (0, 0);
		NewWindow.WindowReference.GetComponent<RectTransform> ().SetPivot(new Vector2 (0, 1));

		NewWindow.WindowReference.name = NewWindow.Name;
		
		if (NewWindow.HasDragZone) {
			NewWindow.DragZone = AddDragZoneToPanel (NewWindow.WindowReference, NewWindow.Position, NewWindow.HeaderHeight);
		}
		// title text
		GameObject NewGuiText;
		if (NewWindow.HasDragZone) {
			RectTransform DragRect = NewWindow.DragZone.GetComponent<RectTransform>();
			NewGuiText = CreateGuiText (NewWindow.Position, new Vector3(DragRect.sizeDelta.x,DragRect.sizeDelta.y, 0), null);
			NewGuiText.transform.SetParent (NewWindow.DragZone.transform);
		} else {
			NewGuiText = CreateGuiText (NewWindow.Position, new Vector3(NewWindow.Size.x,NewWindow.HeaderHeight, 0), null);
			NewGuiText.transform.SetParent (NewWindow.WindowReference.transform);
		}
		if (NewWindow.Name != "") {
			RectTransformExtensions.SetPivotAndAnchors (NewGuiText.GetComponent<RectTransform> (), new Vector2 (0.5f, 1f));
			NewWindow.Title = NewGuiText.GetComponent<Text> ();
			NewWindow.Title.text = NewWindow.Name;
			NewGuiText.GetComponent<Text> ().fontSize = NewWindow.TitleFontSize;
			NewGuiText.GetComponent<Text> ().color = NewWindow.TitleFontColor;
			NewGuiText.GetComponent<Text> ().alignment = TextAnchor.MiddleCenter;
		}

		if (NewWindow.IsCreateModelTexture) {
			GameObject ModelTextureReference = (GameObject) Instantiate (ModelTexturePrefab, new Vector3 (), Quaternion.identity);
			Vector2 ModelTextureMargin = new Vector2(5,5);
			Vector3 ModelTexturePosition = new Vector3 (NewWindow.Position.x+ModelTextureMargin.x, NewWindow.Position.y - NewWindow.HeaderHeight -ModelTextureMargin.y, 0);
			Vector2 ModelTextureSize = new Vector2 (NewWindow.Size.x-ModelTextureMargin.x*2, NewWindow.Size.y-ModelTextureMargin.y*2-NewWindow.HeaderHeight);
			ModelTextureReference.GetComponent<RawImage>();
			SetGuiSettings (ModelTextureReference, ModelTexturePosition, ModelTextureSize);
			ModelTextureReference.transform.SetParent (NewWindow.WindowReference.transform);
		}
		if (NewWindow.IsDunegonCreator) {
			GameObject ModelTextureReference = (GameObject) Instantiate (DungeonTexturePrefab, new Vector3 (), Quaternion.identity);
			Vector2 ModelTextureMargin = new Vector2(5,5);
			Vector3 ModelTexturePosition = new Vector3 (NewWindow.Position.x+ModelTextureMargin.x, NewWindow.Position.y - NewWindow.HeaderHeight -ModelTextureMargin.y, 0);
			Vector2 ModelTextureSize = new Vector2 (NewWindow.Size.x-ModelTextureMargin.x*2, NewWindow.Size.y-ModelTextureMargin.y*2-NewWindow.HeaderHeight);
			ModelTextureReference.GetComponent<RawImage>();
			SetGuiSettings (ModelTextureReference, ModelTexturePosition, ModelTextureSize);
			ModelTextureReference.transform.SetParent (NewWindow.WindowReference.transform);
		}
		
		if (NewWindow.IsCellsItems) {
			Vector3 CellSize = new Vector3 (40, 40, 0);
			MarginPercentageX = 1.1f;
			MarginPercentageY = 1.1f;
			RowsMax = 6;
			ColumnsMax = 6;
			List<GuiCell> MyItemCells = CreateGuiCells(CellSize);
			CreateCells(MyItemCells);
			AttachCellsToParent(MyItemCells, NewWindow.WindowReference, 10f, NewWindow.HeaderHeight+10f);
			AddCellsToGuiInventory(MyItemCells, NewWindow.Name);
		}
		if (NewWindow.IsCellsText) {
			RowsMax = 2;
			ColumnsMax = 8;
			MarginPercentageX = 1;
			MarginPercentageY = 1;
			CreateCells (NewWindow.WindowReference, true, NewGuiSize, "Text", NewWindow.Position, NewWindow.HeaderHeight, NewWindow.CellsReference);
		}
		if (NewWindow.DisplayTexture != null) {
			GameObject NewTexture = new GameObject();
			RawImage MyImage = NewTexture.AddComponent<RawImage>();
			MyImage.texture = NewWindow.DisplayTexture;Vector2 ModelTextureMargin = new Vector2(5,5);
			Vector3 ModelTexturePosition = new Vector3 (NewWindow.Position.x+ModelTextureMargin.x, NewWindow.Position.y - NewWindow.HeaderHeight -ModelTextureMargin.y, 0);
			Vector3 ModelTextureSize = new Vector3 (NewWindow.DisplayTexture.width, NewWindow.DisplayTexture.height, 0);
			SetGuiSettings (NewTexture, ModelTexturePosition, ModelTextureSize);
			NewTexture.transform.SetParent (NewWindow.WindowReference.transform);
		}
		if (NewWindow.IsMap) {
			GameObject NewTexture = (GameObject) Instantiate (MapTexturePrefab, new Vector3 (), Quaternion.identity);
			Vector2 ModelTextureMargin = new Vector2(5,5);
			Vector3 ModelTexturePosition = new Vector3 (NewWindow.Position.x+ModelTextureMargin.x, NewWindow.Position.y - NewWindow.HeaderHeight -ModelTextureMargin.y, 0);
			Vector3 ModelTextureSize = new Vector3 (NewWindow.Size.x-ModelTextureMargin.x*2, NewWindow.Size.y-ModelTextureMargin.y*2-NewWindow.HeaderHeight, 0);
			SetGuiSettings (NewTexture, ModelTexturePosition, ModelTextureSize);
			NewTexture.transform.SetParent (NewWindow.WindowReference.transform);
			GetManager.GetMapCreator().MyRawImage = NewTexture.GetComponent<RawImage>();	// link up the map creator class with the created Raw Image
		}
		if (NewWindow.IsInputText) {
			GameObject NewInputText = (GameObject) Instantiate (NewInputTextPrefab, new Vector3 (), Quaternion.identity);
			Vector2 ModelTextureMargin = new Vector2(5,5);
			Vector3 ModelTexturePosition = new Vector3 (NewWindow.Position.x+ModelTextureMargin.x, NewWindow.Position.y - NewWindow.HeaderHeight -ModelTextureMargin.y, 0);
			Vector3 ModelTextureSize = new Vector3 (NewWindow.Size.x-ModelTextureMargin.x*2, NewWindow.Size.y-ModelTextureMargin.y*2-NewWindow.HeaderHeight, 0);
			SetGuiSettings (NewInputText, ModelTexturePosition, ModelTextureSize);
			NewInputText.transform.SetParent (NewWindow.WindowReference.transform);
			// add function to input text on press enter lol
			NewInputText.GetComponent<InputField>().onEndEdit.AddListener(delegate {DestroyInputWindow ();});
		}

		if (NewWindow.HasCloseButton) {
			AddCloseButtonToWindow (NewWindow.WindowReference, NewWindow.Size, NewWindow.Position);
		}
		if (NewWindow.IsResizable) {
			AddResizezoneToWindow (NewWindow.WindowReference, NewWindow.Position, NewWindow.HeaderHeight);
		}


		// now attach the window to the canvas - one for each set of windows - ie main window, or in game menu
		NewWindow.WindowReference.GetComponent<RectTransform>().SetParent (MyCanvas.GetComponent<RectTransform>(), false);

		if (NewWindow.IsToggler) {
			// add state toggler button
			GetManager.GetGuiManager ().MyMenuButtons [WindowIndex].GetComponent<Button> ().onClick.AddListener (
					NewWindow.WindowReference.GetComponent<ActiveStateToggler> ().ToggleActive
				);
			// link up the windows state toggler to the button that toggles it
			NewWindow.WindowReference.GetComponent<ActiveStateToggler> ().MyButton = GetManager.GetGuiManager ().MyMenuButtons [WindowIndex].GetComponent<Button> ();
			GetManager.GetGuiManager ().MyMenuButtons [WindowIndex].transform.GetChild (0).GetComponent<Text> ().text = NewWindow.Name;
		}
		NewWindow.WindowReference.transform.localScale = NewWindow.Scale;
		NewWindow.WindowReference.SetActive (false);	// set them inactive by default

		return NewWindow.WindowReference;
	}
Esempio n. 46
0
        public void CloseItemClosesAndWindowViewModelIfCanCloseReturnsTrue()
        {
            var model = new Mock<IMyScreen>();
            var window = new MyWindow();
            this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model.Object)).Returns(window);
            object parent = null;
            model.SetupSet(x => x.Parent = It.IsAny<object>()).Callback((object x) => parent = x);
            this.windowManager.CreateWindow(model.Object, true);

            model.Setup(x => x.CanCloseAsync()).ReturnsAsync(true);
            ((IChildDelegate)parent).CloseItem(model.Object);

            model.Verify(x => x.Close());
            Assert.True(window.OnClosedCalled);
        }
Esempio n. 47
0
	// shouldn't need to do this every screen
	// if MyStats.HasUpdated
	// this should be able to be updated for any player -> ie check out a bots stats
	public void SetStats(MyWindow NewWindow, BaseCharacter MyCharacter) {
		if (NewWindow.IsStats) {
			if (MyCharacter != null)
			if (MyCharacter.MyStats.HasUpdated || IsInitialUpdate) {
				NewWindow.Title.text = "Stats of: " +MyCharacter.name;
				if (MyCharacter.MyStats.MyLevel.SkillPoints > 0)
					NewWindow.Title.text += " - SkillPoints [" + MyCharacter.MyStats.MyLevel.SkillPoints.ToString () + "]";
				if (MyCharacter.MyStats.MyLevel.SkillPoints > 0) {
					// enable +/- buttons
					for (int i = 0; i < IncreaseStatsButtons.Count; i++) {
						IncreaseStatsButtons [i].SetActive (true);
					}
				} else {
					// disable +/- buttons
					for (int i = 0; i < IncreaseStatsButtons.Count; i++) {
						IncreaseStatsButtons [i].SetActive (false);
					}
				}

				UpdateText ("Strength: " + MyCharacter.MyStats.GetAttributeFromList ("Strength").Base.ToString (), 0, 0, NewWindow);
				UpdateText ("Vitality: " + MyCharacter.MyStats.GetAttributeFromList ("Vitality").Base.ToString (), 0, 1, NewWindow);
				UpdateText ("Intelligence: " + MyCharacter.MyStats.GetAttributeFromList ("Intelligence").Base.ToString (), 0, 2, NewWindow);
				UpdateText ("Wisdom: " + MyCharacter.MyStats.GetAttributeFromList ("Wisdom").Base.ToString (), 0, 3, NewWindow);
				UpdateText ("Agility: " + MyCharacter.MyStats.GetAttributeFromList ("Agility").Base.ToString (), 0, 4, NewWindow);
				UpdateText ("Dexterity: " + MyCharacter.MyStats.GetAttributeFromList ("Dexterity").Base.ToString (), 0, 5, NewWindow);
				UpdateText ("Luck: " + MyCharacter.MyStats.GetAttributeFromList ("Luck").Base.ToString (), 0, 6, NewWindow);
				UpdateText ("Charisma: " + MyCharacter.MyStats.GetAttributeFromList ("Charisma").Base.ToString (), 0, 7, NewWindow);
		
				UpdateText ("Health: " + MyCharacter.MyStats.GetStatFromList ("Health").Max.ToString (), 1, 0, NewWindow);
				UpdateText ("HealthRegen: " + MyCharacter.MyStats.GetStatFromList ("Health").Regeneration.ToString (), 1, 1, NewWindow);
				UpdateText ("Mana: " + MyCharacter.MyStats.GetStatFromList ("Mana").Max.ToString (), 1, 2, NewWindow);
				UpdateText ("ManaRegen: " + MyCharacter.MyStats.GetStatFromList ("Mana").Regeneration.ToString (), 1, 3, NewWindow);
				UpdateText ("Energy: " + MyCharacter.MyStats.GetStatFromList ("Energy").Max.ToString (), 1, 4, NewWindow);
				UpdateText ("EnergyRegen: " + MyCharacter.MyStats.GetStatFromList ("Energy").Regeneration.ToString (), 1, 5, NewWindow);
				MyCharacter.MyStats.HasUpdated = false;
				IsInitialUpdate = false;
			}
		}
	}