Ejemplo n.º 1
0
        /// <summary>
        ///     Catch on minimize event
        ///     @author : Asbjørn Ulsberg -=|=- [email protected]
        /// </summary>
        /// <param name="msg"></param>
        protected override void WndProc(ref Message msg)
        {
            if (msg.Msg == WM_SIZE &&
                (int)msg.WParam == SIZE_MINIMIZED)
            {
                Minimized?.Invoke(this, EventArgs.Empty);
            }

            base.WndProc(ref msg);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines whether the specified object is equal to the current object.
        /// </summary>
        /// <param name="other">The <see cref="UiListItem"/> to compare with the current <see cref="UiListItem"/>.</param>
        /// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.</returns>
        /// <stable>ICU 55</stable>
        public bool Equals(UiListItem other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(NameInDisplayLocale.Equals(other.NameInDisplayLocale) &&
                   NameInSelf.Equals(other.NameInSelf) &&
                   Minimized.Equals(other.Minimized) &&
                   Modified.Equals(other.Modified));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines whether the specified object is equal to the current object.
        /// </summary>
        /// <param name="obj">The object to compare with the current object.</param>
        /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
        /// <stable>ICU 55</stable>
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null || !(obj is UiListItem))
            {
                return(false);
            }
            UiListItem other = (UiListItem)obj;

            return(NameInDisplayLocale.Equals(other.NameInDisplayLocale) &&
                   NameInSelf.Equals(other.NameInSelf) &&
                   Minimized.Equals(other.Minimized) &&
                   Modified.Equals(other.Modified));
        }
Ejemplo n.º 4
0
        public MainWindow( )
        {
            InitializeComponent();
            var presenter = new MainPresenter();

            presenter.SetupView(this);

            Loaded       += (s, e) => WindowLoaded?.Invoke();
            Closing      += (s, e) => ClosingWindow?.Invoke();
            StateChanged += (s, e) => {
                if (this.WindowState == WindowState.Minimized)
                {
                    Minimized?.Invoke();
                }
                else if (this.WindowState == WindowState.Normal)
                {
                    Unminimized?.Invoke();
                }
            };
        }
Ejemplo n.º 5
0
        private void RegisterWindowCallbacks()
        {
            if (_callbackRegistered)
            {
                return;
            }
            _callbackRegistered = true;

            // [NOTE]
            // Do not register callback to GLFW as lambda or method. (That cannot work)
            // Put delegate on a field and register it to GLFW.

            _posCallback = (wnd, x, y) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                _location = new Vector2i(x, y);
                Move?.Invoke(this, new WindowPositionEventArgs(x, y));
            };
            GLFW.SetWindowPosCallback(_window, _posCallback);

            _sizeCallback = (wnd, width, height) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                GLFW.GetWindowFrameSize(_window, out var left, out var top, out var right, out var bottom);
                _clientSize = new Vector2i(width, height);
                _size       = new Vector2i(_clientSize.X + left + right, _clientSize.Y + top + bottom);
                Resize?.Invoke(this, new ResizeEventArgs(width, height));
            };
            GLFW.SetWindowSizeCallback(_window, _sizeCallback);

            _frameBufferSizeCallback = (wnd, width, height) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                _frameBufferSize = new Vector2i(width, height);
                FrameBufferSizeChanged?.Invoke(this, _frameBufferSize);
            };
            GLFW.SetFramebufferSizeCallback(_window, _frameBufferSizeCallback);

            _closeCallback = wnd =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var cancel = false;
                var e      = new CancelEventArgs(&cancel);
                Closing?.Invoke(this, e);
                if (e.Cancel)
                {
                    GLFW.SetWindowShouldClose(_window, false);
                }
            };
            GLFW.SetWindowCloseCallback(_window, _closeCallback);


            _iconifyCallback = (wnd, minimized) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                Minimized?.Invoke(this, new MinimizedEventArgs(minimized));
            };
            GLFW.SetWindowIconifyCallback(_window, _iconifyCallback);

            _focusCallback = (wnd, focused) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                FocusedChanged?.Invoke(this, new FocusedChangedEventArgs(focused));
            };
            GLFW.SetWindowFocusCallback(_window, _focusCallback);

            _charCallback = (wnd, unicode) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                CharInput?.Invoke(this, new CharInputEventArgs(unicode));
            };
            GLFW.SetCharCallback(_window, _charCallback);

            _keyCallback = (wnd, glfwKey, scanCode, action, glfwMods) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var e = new KeyboardKeyEventArgs(glfwKey, scanCode, glfwMods, action == GlfwInputAction.Repeat);

                if (action == GlfwInputAction.Release)
                {
                    KeyUp?.Invoke(this, e);
                }
                else
                {
                    KeyDown?.Invoke(this, e);
                }
            };
            GLFW.SetKeyCallback(_window, _keyCallback);

            _cursorEnterCallback = (wnd, entered) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                if (entered)
                {
                    MouseEnter?.Invoke(this);
                }
                else
                {
                    MouseLeave?.Invoke(this);
                }
            };
            GLFW.SetCursorEnterCallback(_window, _cursorEnterCallback);

            _mouseButtonCallback = (wnd, button, action, mods) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var e = new MouseButtonEventArgs(button, action, mods);

                if (action == GlfwInputAction.Release)
                {
                    MouseUp?.Invoke(this, e);
                }
                else
                {
                    MouseDown?.Invoke(this, e);
                }
            };
            GLFW.SetMouseButtonCallback(_window, _mouseButtonCallback);

            _cursorPosCallback = (wnd, posX, posY) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var e = new MouseMoveEventArgs(new Vector2((int)posX, (int)posY));
                MouseMove?.Invoke(this, e);
            };
            GLFW.SetCursorPosCallback(_window, _cursorPosCallback);

            _scrollCallback = (wnd, offsetX, offsetY) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var e = new MouseWheelEventArgs((float)offsetX, (float)offsetY);
                MouseWheel?.Invoke(this, e);
            };
            GLFW.SetScrollCallback(_window, _scrollCallback);

            _dropCallback = (wnd, count, paths) =>
            {
                if (wnd != _window)
                {
                    return;
                }
                var e = new FileDropEventArgs(count, paths);
                FileDrop?.Invoke(this, e);
            };
            GLFW.SetDropCallback(_window, _dropCallback);

            _joystickCallback = (joystick, state) =>
            {
                var e = new JoystickConnectionEventArgs(joystick, state == GlfwConnectedState.Connected);
                JoystickConnectionChanged?.Invoke(this, e);
            };
            GLFW.SetJoystickCallback(_joystickCallback);

            _monitorCallback = (monitor, state) =>
            {
                var e = new MonitorConnectionEventArgs(monitor, state == GlfwConnectedState.Connected);
                MonitorConnectionChanged?.Invoke(this, e);
            };
            GLFW.SetMonitorCallback(_monitorCallback);

            _refreshCallback = wnd =>
            {
                if (wnd != _window)
                {
                    return;
                }
                Refresh?.Invoke(this);
            };
            GLFW.SetWindowRefreshCallback(_window, _refreshCallback);
        }
Ejemplo n.º 6
0
        public static void SaveConfiguration()
        {
            string fullFileName = Path.Combine(Assembly.GetExecutingAssembly().Location, fileName);

            if (!LocalConfig)
            {
                fullFileName = Path.Combine(GetLocalStoragePath(), fileName);
            }
            if (File.Exists(fullFileName))
            {
                FileInfo fileInfo = new FileInfo(fullFileName);
                fileInfo.Attributes = FileAttributes.Normal;
            }
            XmlWriterSettings xwSettings = new XmlWriterSettings();

            xwSettings.Indent = true;
            MemoryStream ms = new MemoryStream();

            using (XmlWriter xw = XmlWriter.Create(ms, xwSettings)) {
                xw.WriteStartDocument();
                xw.WriteStartElement("config");
                xw.WriteStartElement("integrators");
                foreach (string url in FarmList)
                {
                    xw.WriteStartElement("integrator");
                    xw.WriteAttributeString("url", url);
                    xw.WriteEndElement();
                }
                xw.WriteEndElement();
                xw.WriteStartElement("buildNotifications");
                foreach (BuildNotificationViewInfo bnvi in buildNotifications)
                {
                    xw.WriteStartElement("notification");
                    xw.WriteRaw(SmartCCNetHelper.GetSerializeString(bnvi.Notification));
                    xw.WriteEndElement();
                }
                xw.WriteEndElement();
                xw.WriteStartElement("PowerShellScripts");
                foreach (PSScript script in powerShellScripts)
                {
                    xw.WriteStartElement("PowerShellScript");
                    xw.WriteRaw(SmartCCNetHelper.GetSerializeString(script));
                    xw.WriteEndElement();
                }
                xw.WriteEndElement();
                xw.WriteStartElement("lastProjectDurationDictionary");
                byte[] lastBuildDurationData = ProjectInfo.GetLastBuildDurationDictSaveData();
                xw.WriteBase64(lastBuildDurationData, 0, lastBuildDurationData.Length);
                xw.WriteEndElement();
                xw.WriteStartElement("layoutXml");
                xw.WriteRaw(layoutXml);
                xw.WriteEndElement();
                xw.WriteStartElement("gridProjectXml");
                xw.WriteRaw(gridProjectXml);
                xw.WriteEndElement();
                xw.WriteStartElement("gridTestsXml");
                xw.WriteRaw(gridTestsXml);
                xw.WriteEndElement();
                xw.WriteStartElement("gridServersXml");
                xw.WriteRaw(gridServersXml);
                xw.WriteEndElement();
                xw.WriteStartElement("gridNotificationsXml");
                xw.WriteRaw(gridNotificationsXml);
                xw.WriteEndElement();
                xw.WriteElementString("volunteerColorString", VolunteerColorString);
                xw.WriteElementString("alwaysOnTop", AlwaysOnTop.ToString());
                xw.WriteElementString("refreshTime", RefreshTime.ToString());
                xw.WriteElementString("minimized", Minimized.ToString());
                xw.WriteElementString("buildLogMaximized", BuildLogMaximized.ToString());
                xw.WriteElementString("formWidth", FormWidth.ToString());
                xw.WriteElementString("formHeight", FormHeight.ToString());
                xw.WriteElementString("formLeft", FormLeft.ToString());
                xw.WriteElementString("formTop", FormTop.ToString());
                xw.WriteElementString("updateUrl", UpdateUrl);
                xw.WriteElementString("workUserName", WorkUserName);
                xw.WriteElementString("useSkin", UseSkin.ToString());
                xw.WriteElementString("UsePowerShellScript", UsePowerShellScript.ToString());
                xw.WriteElementString("needAskForStutup", NeedAskForStutup.ToString());
                xw.WriteElementString("alreadyReloadGridTestsLayout", AlreadyReloadGridTestsLayout.ToString());
                xw.WriteElementString("skinName", SkinName);
                xw.WriteElementString("popupHideTimeout", PopupHideTimeout.ToString());
                xw.WriteStartElement("trackedProjects");
                foreach (ProjectShortInfo info in TrackedProjects)
                {
                    xw.WriteStartElement("trackedProject");
                    xw.WriteAttributeString("name", info.Name);
                    xw.WriteAttributeString("status", info.BuildStatus);
                    xw.WriteEndElement();
                }
                xw.WriteEndElement();
                xw.WriteEndElement();
                xw.WriteEndDocument();
            }
            File.WriteAllBytes(fullFileName, ms.ToArray());
        }
Ejemplo n.º 7
0
        public UIWindow(Scene parentScene, Point contentSize, bool canBeClosed, bool canBeMaximized,
                        bool canbeMinimized, SpriteFrame icon, UIStyle style)
        {
            this.style = style;
            var headerSize = 32;
            var windowRoot = parentScene.AddActor("Window");

            new BoundingRect(windowRoot,
                             contentSize + new Point(0, headerSize) + new Point(this.margin * 2, this.margin * 2));

            var rootGroup = new LayoutGroup(windowRoot, Orientation.Vertical);

            rootGroup.SetMarginSize(new Point(this.margin, this.margin));
            rootGroup.AddHorizontallyStretchedElement("HeaderContent", 32, headerContentActor =>
            {
                new Hoverable(headerContentActor);
                new Draggable(headerContentActor).DragStart +=
                    (position, delta) => OnAnyPartOfWindowClicked(MouseButton.Left);
                new MoveOnDrag(headerContentActor, windowRoot.transform);

                var headerGroup = new LayoutGroup(headerContentActor, Orientation.Horizontal);
                if (icon != null)
                {
                    headerGroup.AddVerticallyStretchedElement("Icon", 32, iconActor =>
                    {
                        new SpriteRenderer(iconActor, icon.spriteSheet).SetAnimation(icon.animation);

                        iconActor.GetComponent <BoundingRect>().SetOffsetToCenter();
                    });
                    headerGroup.PixelSpacer(5); // Spacing between icon and title
                }

                headerGroup.AddBothStretchedElement("Title",
                                                    titleActor =>
                {
                    this.titleTextRenderer = new BoundedTextRenderer(titleActor, "Window title goes here",
                                                                     style.uiElementFont, Color.White, Alignment.CenterLeft,
                                                                     depthOffset: -2).EnableDropShadow(Color.Black);
                });

                if (canbeMinimized)
                {
                    CreateControlButton(headerGroup, windowRoot, win => Minimized?.Invoke(win),
                                        this.style.minimizeButtonFrames);
                }

                if (canBeMaximized)
                {
                    CreateControlButton(headerGroup, windowRoot, win => Maximized?.Invoke(win),
                                        this.style.maximizeButtonFrames);
                }

                if (canBeClosed)
                {
                    CreateControlButton(headerGroup, windowRoot, win => Closed?.Invoke(win),
                                        this.style.closeButtonFrames);
                }
            });

            // These variables with _local at the end of their name are later assigned to readonly values
            // The locals are assigned in lambdas which is illegal for readonly assignment
            SceneRenderer sceneRenderer_local = null;
            Actor         canvasActor_local   = null;
            LayoutGroup   contentGroup_local  = null;

            // "Content" means everything below the header

            rootGroup.AddBothStretchedElement("ContentGroup", contentActor =>
            {
                new NinepatchRenderer(contentActor, style.windowSheet, NinepatchSheet.GenerationDirection.Outer);

                contentGroup_local = new LayoutGroup(contentActor, Orientation.Horizontal)
                                     .AddBothStretchedElement("Canvas", viewActor =>
                {
                    canvasActor_local = viewActor;
                    new BoundedCanvas(viewActor);
                    new Hoverable(viewActor);
                    new Clickable(viewActor).ClickStarted += OnAnyPartOfWindowClicked;
                    sceneRenderer_local = new SceneRenderer(viewActor);
                })
                ;
            })
            ;

            this.sceneRenderer    = sceneRenderer_local;
            this.canvasActor      = canvasActor_local;
            this.rootTransform    = windowRoot.transform;
            this.rootBoundingRect = windowRoot.GetComponent <BoundingRect>();
            this.contentGroup     = contentGroup_local;
        }
 /// <summary>
 /// Raises the Minimized event.
 /// </summary>
 private void OnMinimized() =>
 Minimized?.Invoke(this);