Пример #1
0
            public HResult UpdateButton(int cookie, INiTitleBarButton button)
            {
                try
                {
                    if (button == null)
                    {
                        throw new ArgumentNullException("button");
                    }

                    TitleBarButton wrapper;
                    if (!_buttonMap.TryGetValue(cookie, out wrapper))
                    {
                        return(HResult.False);
                    }

                    wrapper.Update(button);

                    var formChrome = _mainWindowChrome.FormChrome;
                    if (formChrome != null)
                    {
                        formChrome.PaintNonClientArea();
                    }

                    return(HResult.OK);
                }
                catch (Exception ex)
                {
                    return(ErrorUtil.GetHResult(ex));
                }
            }
Пример #2
0
            public HResult AddButton(INiTitleBarButton button, out int cookie)
            {
                cookie = 0;

                try
                {
                    if (button == null)
                    {
                        throw new ArgumentNullException("button");
                    }

                    cookie = _nextCookie++;

                    var wrapper = new TitleBarButton(this, cookie);
                    wrapper.Update(button);

                    _buttonMap.Add(cookie, wrapper);
                    _buttons.Add(wrapper);

                    RebuildButtons();

                    return(HResult.OK);
                }
                catch (Exception ex)
                {
                    return(ErrorUtil.GetHResult(ex));
                }
            }
            public HResult AddButton(INiTitleBarButton button, out int cookie)
            {
                cookie = 0;

                try
                {
                    if (button == null)
                        throw new ArgumentNullException("button");

                    cookie = _nextCookie++;

                    var wrapper = new TitleBarButton(this, cookie);
                    wrapper.Update(button);

                    _buttonMap.Add(cookie, wrapper);
                    _buttons.Add(wrapper);

                    RebuildButtons();

                    return HResult.OK;
                }
                catch (Exception ex)
                {
                    return ErrorUtil.GetHResult(ex);
                }
            }
Пример #4
0
                public void Update(INiTitleBarButton button)
                {
                    int priority;

                    ErrorUtil.ThrowOnFailure(button.GetPriority(out priority));
                    Priority = priority;

                    Color?foreColor;

                    ErrorUtil.ThrowOnFailure(button.GetForeColor(out foreColor));
                    ForeColor = foreColor;

                    Color?backColor;

                    ErrorUtil.ThrowOnFailure(button.GetBackColor(out backColor));
                    BackColor = backColor;

                    bool enabled;

                    ErrorUtil.ThrowOnFailure(button.GetEnabled(out enabled));
                    Enabled = enabled;

                    bool visible;

                    ErrorUtil.ThrowOnFailure(button.GetVisible(out visible));
                    Visible = visible;

                    IResource resource;

                    ErrorUtil.ThrowOnFailure(button.GetImage(out resource));
                    SetImage(resource);

                    if (ChromeButton != null)
                    {
                        ChromeButton.Enabled = enabled;
                        ChromeButton.Visible = visible;
                    }
                }
                public void Update(INiTitleBarButton button)
                {
                    int priority;
                    ErrorUtil.ThrowOnFailure(button.GetPriority(out priority));
                    Priority = priority;

                    Color? foreColor;
                    ErrorUtil.ThrowOnFailure(button.GetForeColor(out foreColor));
                    ForeColor = foreColor;

                    Color? backColor;
                    ErrorUtil.ThrowOnFailure(button.GetBackColor(out backColor));
                    BackColor = backColor;

                    bool enabled;
                    ErrorUtil.ThrowOnFailure(button.GetEnabled(out enabled));
                    Enabled = enabled;

                    bool visible;
                    ErrorUtil.ThrowOnFailure(button.GetVisible(out visible));
                    Visible = visible;

                    IResource resource;
                    ErrorUtil.ThrowOnFailure(button.GetImage(out resource));
                    SetImage(resource);

                    if (ChromeButton != null)
                    {
                        ChromeButton.Enabled = enabled;
                        ChromeButton.Visible = visible;
                    }
                }
            public HResult UpdateButton(int cookie, INiTitleBarButton button)
            {
                try
                {
                    if (button == null)
                        throw new ArgumentNullException("button");

                    TitleBarButton wrapper;
                    if (!_buttonMap.TryGetValue(cookie, out wrapper))
                        return HResult.False;

                    wrapper.Update(button);

                    var formChrome = _mainWindowChrome.FormChrome;
                    if (formChrome != null)
                        formChrome.PaintNonClientArea();

                    return HResult.OK;
                }
                catch (Exception ex)
                {
                    return ErrorUtil.GetHResult(ex);
                }
            }