Exemplo n.º 1
0
        private void UpdateIcon(IconState newState)
        {
            iconState = newState;

            switch (iconState)
            {
            case IconState.TypeIndication:
                // Show icon image
                IconImage.Source           = Document.SmallIcon;
                IconImageBorder.Visibility = Visibility.Visible;

                // Hide previously shown previewControl
                if (previewControl != null)
                {
                    previewControl.Visibility = Visibility.Collapsed;
                }
                break;

            case IconState.ContentPreview:
                // Hide icon image
                IconImageBorder.Visibility = Visibility.Collapsed;

                // Show a previouly hidden preview control or generate a new one
                if (previewControl != null)
                {
                    previewControl.Visibility = Visibility.Visible;
                }
                else
                {
                    previewControl = GeneratePreviewIcon();
                    IconContentGrid.Children.Add(previewControl);
                }
                break;
            }
        }
Exemplo n.º 2
0
    private void SetIconState(IconState state)
    {
        switch (state)
        {
        case IconState.Normal: {
            healthStatusBG.color = normalColor;
            break;
        }

        case IconState.Hurt: {
            healthStatusBG.color    = hurtColor;
            lastIconChangeTimestamp = Time.time;
            break;
        }

        case IconState.Heal: {
            healthStatusBG.color    = healingColor;
            lastIconChangeTimestamp = Time.time;
            hbGlowyBackground.Simulate(0f, false, true, true);
            hbExplosion.Simulate(0f, false, true, true);
            hbExplosionDark.Simulate(0f, false, true, true);
            break;
        }
        }
        currentState = state;
    }
Exemplo n.º 3
0
        private void SetDLIcon(int index, IconState state)
        {
            if (!_dlDict.ContainsKey(index))
            {
                return;
            }
            var target = _dlDict[index];

            switch (state)
            {
            case IconState.None:
                target.nameBG.color  = colors[1];
                target.nameLbl.color = colors[1];
                target.sliderGo.SetActive(false);
                target.downGo.SetActive(true);
                target.goldGo.SetActive(false);
                break;

            case IconState.Freeze:
                target.nameBG.color  = colors[0];
                target.nameLbl.color = colors[0];
                target.sliderGo.SetActive(true);
                target.downGo.SetActive(false);
                target.goldGo.SetActive(false);
                break;

            case IconState.Action:
                target.nameBG.color  = colors[1];
                target.nameLbl.color = colors[1];
                target.sliderGo.SetActive(false);
                target.downGo.SetActive(false);
                target.goldGo.SetActive(true);
                break;
            }
        }
Exemplo n.º 4
0
        public void SetBoneState(int index, IconState state)
        {
            SetDLIcon(index, state);
            if (!_boneDict.ContainsKey(index))
            {
                return;
            }
            var bone = _boneDict[index];

            if (!bone.ContainsKey(state))
            {
                return;
            }
            var target = bone[state];

            if (_animation[index].lastAnimationName.Equals(target))
            {
                return;
            }
            _animation[index]?.Play(target);
            if (state != IconState.Action)
            {
                _animation[index].Stop();
            }
        }
Exemplo n.º 5
0
        internal virtual TagBuilder BuildDropdownButton()
        {
            var dropdownButton = new TagBuilder("button");

            dropdownButton.Attributes.Add("id", Id);
            dropdownButton.Attributes.Add("type", "button");
            dropdownButton.Attributes.Add("class", DropdownButtonClasses);
            dropdownButton.Attributes.Add("data-toggle", "dropdown");
            dropdownButton.Attributes.Add("aria-haspopup", "true");
            dropdownButton.Attributes.Add("aria-expanded", "false");

            if (Mode == DropdownMode.Icon)
            {
                var iconClasses = IconState.IsUsed() ? $"kt-font-{IconState.ToValue()}" : "";

                dropdownButton.InnerHtml.AppendHtml(Icon.ToIconContent(iconClasses));
            }
            else if (Mode == DropdownMode.Split)
            {
                dropdownButton.InnerHtml.AppendHtml("<span class='sr-only'>Toggle Dropdown</span>");
            }
            else
            {
                dropdownButton.InnerHtml.Append(Text);
            }

            return(dropdownButton);
        }
        public override async void OnTick()
        {
            IconState newState = IconState.None;

            if (!_fsIpc.GearIsRetractable)
            {
                newState = IconState.InActive;
            }
            else
            {
                if (_fsIpc.GearIsInTransit)
                {
                    newState = IconState.Transit;
                }
                else
                {
                    newState = _fsIpc.GearControlIsUp ? IconState.Up : IconState.Down;
                }
            }
            if (_currentIconState == newState)
            {
                return;
            }
            _currentIconState = newState;
            await DrawIcon(newState);
        }
Exemplo n.º 7
0
        private object ProcessRequest(object res, object state)
        {
            var message = utility.DeserializeFromObject <NotificationMessage>(res);

            if (message == null)
            {
                return(null);
            }

            iconState = (message.TurnOn) ? IconState.On : IconState.Off;

            if (iconState == IconState.On)
            {
                ni.Icon = onIcon;

                var title = message.WindowsNotification.Title;
                var text  = message.WindowsNotification.Text;

                windowsNotificationService.ShowNotification(title, text);
            }
            else
            {
                ni.Icon = offIcon;
            }

            return(null);
        }
Exemplo n.º 8
0
 private void FadeChildren(IconState nextState)
 {
     foreach (ClickMenuIcon child in childMenus)
     {
         child.StartFade(nextState);
     }
 }
Exemplo n.º 9
0
        private void StartFade(IconState nextState)
        {
            FadeParameters prev = fades[0];

            if (prev.state == nextState)
            {
                return;
            }

            if (fades.Count > 1)
            {
                // A fade is currently in progress. Save off any values where they are now.
                float t = GetCurrentProgress();
                alphaAtFadeStart     = GetCurrentAlpha();
                scaleAtFadeStart     = Mathf.Lerp(scaleAtFadeStart, prev.scale, t);
                zOffsetAtFadeStart   = GetCurrentZOffset();
                highlightAtFadeStart = GetCurrentHighlight();

                // Delete any old fades
                fades.RemoveRange(1, fades.Count - 1);
            }

            FadeParameters nextFade = new FadeParameters(nextState, prev.state);

            fades.Insert(0, nextFade);

            timeAtFadeStart = Time.time;
            buttonActive    = nextFade.buttonActive;

            if (!buttonActive)
            {
                // Collisions are only allowed on active buttons.
                meshCollider.sharedMesh = null;
            }
        }
Exemplo n.º 10
0
        public void StartFadeOnIcon(ConstellationMenuIcon icon,
                                    IconState newState)
        {
            bool hoverChanged = false;

            if (newState == IconState.Hovering)
            {
                if (hoverIcon != null)
                {
                    hoverIcon.FadeIfNeeded(IconState.Hovering,
                                           IconState.Shown);
                }
                hoverIcon    = icon;
                hoverChanged = true;
            }

            if (icon == hoverIcon &&
                newState == IconState.Closed)
            {
                hoverIcon    = null;
                hoverChanged = true;
            }

            if (hoverChanged)
            {
                dummyParent.OnHoverChange(GetHoverIcon());
            }
        }
        public SparkleStatusIconController()
        {
            Program.Controller.FolderListChanged += delegate {
                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error)
                    CurrentState = IconState.Idle;

                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnSyncing += delegate {
                CurrentState = IconState.Syncing;

                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (IconState.Syncing);
            };

            Program.Controller.OnError += delegate {
                CurrentState = IconState.Error;

                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (IconState.Error);
            };
        }
Exemplo n.º 12
0
            public FadeParameters(IconState nextState)
            {
                state = nextState;
                switch (state)
                {
                case IconState.Shown:
                    alpha        = SHOWN_ICON_ALPHA;
                    buttonActive = true;
                    colliderSize = COLLIDER_SIZE;
                    break;

                case IconState.Hovering:
                    alpha        = SHOWN_ICON_ALPHA;
                    buttonActive = true;
                    colliderSize = COLLIDER_SIZE;
                    break;

                case IconState.Hidden:
                    alpha        = HIDDEN_ICON_ALPHA;
                    buttonActive = true;
                    colliderSize = HIDDEN_COLLIDER_SIZE;
                    break;

                case IconState.Closed:
                    alpha        = DEFAULT_ICON_ALPHA;
                    buttonActive = false;
                    colliderSize = 0.0f;
                    break;
                }
            }
Exemplo n.º 13
0
        public void InterpolateBetween(IconState firstState, IconState secondState, float interpolationValue)
        {
                        #if DEBUG
            if (float.IsNaN(interpolationValue))
            {
                throw new Exception("interpolationValue cannot be NaN");
            }
                        #endif
            bool  setIntensity         = true;
            float IntensityFirstValue  = 0;
            float IntensitySecondValue = 0;
            switch (firstState)
            {
            case  IconState.Selected:
                IntensityFirstValue = 1f;
                if (interpolationValue < 1)
                {
                    this.HighlightSpriteVisible = true;
                }
                break;

            case  IconState.NotSelected:
                IntensityFirstValue = 0.5f;
                if (interpolationValue < 1)
                {
                    this.HighlightSpriteVisible = false;
                }
                break;
            }
            switch (secondState)
            {
            case  IconState.Selected:
                IntensitySecondValue = 1f;
                if (interpolationValue >= 1)
                {
                    this.HighlightSpriteVisible = true;
                }
                break;

            case  IconState.NotSelected:
                IntensitySecondValue = 0.5f;
                if (interpolationValue >= 1)
                {
                    this.HighlightSpriteVisible = false;
                }
                break;
            }
            if (setIntensity)
            {
                Intensity = IntensityFirstValue * (1 - interpolationValue) + IntensitySecondValue * interpolationValue;
            }
            if (interpolationValue < 1)
            {
                mCurrentIconStateState = (int)firstState;
            }
            else
            {
                mCurrentIconStateState = (int)secondState;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public StatusIconController()
        {
            InitAnimation();

            // A remote folder has been added.
            Program.Controller.FolderListChanged += delegate {
                if (CurrentState != IconState.Error)
                {
                    CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0)
                    {
                        StateText = Properties_Resources.ResourceManager.GetString("Welcome", CultureInfo.CurrentCulture);
                    }
                    else
                    {
                        StateText = Properties_Resources.ResourceManager.GetString("FilesUpToDate", CultureInfo.CurrentCulture);
                    }
                }

                UpdateStatusItemEvent(StateText);
                UpdateMenuEvent(CurrentState);
            };

            // No more download/upload.
            Program.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error)
                {
                    CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0)
                    {
                        StateText = Properties_Resources.ResourceManager.GetString("Welcome", CultureInfo.CurrentCulture);
                    }
                    else
                    {
                        StateText = Properties_Resources.ResourceManager.GetString("FilesUpToDate", CultureInfo.CurrentCulture);
                    }
                }

                UpdateStatusItemEvent(StateText);

                this.animation.Stop();

                UpdateIconEvent(0);
                UpdateMenuEvent(CurrentState);
            };

            // Syncing.
            Program.Controller.OnSyncing += delegate {
                CurrentState = IconState.Syncing;
                StateText    = Properties_Resources.ResourceManager.GetString("SyncingChanges", CultureInfo.CurrentCulture);

                UpdateStatusItemEvent(StateText);

                this.animation.Start();
            };
        }
Exemplo n.º 15
0
        /// <summary>
        /// Prepare data for animation and start animation if need.
        /// </summary>
        private void InitializeAnimator()
        {
            animTimer          = new Timer();
            animTimer.Elapsed += AnimTimer_Elapsed;

            dataSource = TaskbarIconDataSource.Instance;
            iconState  = IconState.Idle;
            OnIconStateChanged();
        }
Exemplo n.º 16
0
 /// Starts a fade if the there is a match for fromState
 public void FadeIfNeeded(IconState fromState,
                          IconState toState)
 {
     if (state != fromState)
     {
         return;
     }
     StartFade(toState);
 }
Exemplo n.º 17
0
 /// Starts a fade if the there is a match for fromState
 private void FadeIfNeeded(IconState fromState,
                           IconState toState)
 {
     if (fades[0].state != fromState)
     {
         return;
     }
     StartFade(toState);
 }
Exemplo n.º 18
0
        public void GetFrameIndexTest()
        {
            IconState target = new IconState(); // TODO: Initialize to an appropriate value
            target.NumDirections = 4;

            // Directionality.
            Assert.AreEqual(0, target.GetFrameIndex(0, Direction.SOUTH, NoLengthChecks: true), "SOUTH:0 does not produce frame 0.");
            Assert.AreEqual(1, target.GetFrameIndex(0, Direction.NORTH, NoLengthChecks: true), "NORTH:0 does not produce frame 1.");
            Assert.AreEqual(2, target.GetFrameIndex(0, Direction.EAST, NoLengthChecks: true), "EAST:0 does not produce frame 2.");
            Assert.AreEqual(3, target.GetFrameIndex(0, Direction.WEST, NoLengthChecks: true), "WEST:0 does not produce frame 3.");
        }
Exemplo n.º 19
0
        public void GetFrameIndexTest()
        {
            IconState target = new IconState(); // TODO: Initialize to an appropriate value

            target.NumDirections = 4;

            // Directionality.
            Assert.AreEqual(0, target.GetFrameIndex(0, Direction.SOUTH, NoLengthChecks: true), "SOUTH:0 does not produce frame 0.");
            Assert.AreEqual(1, target.GetFrameIndex(0, Direction.NORTH, NoLengthChecks: true), "NORTH:0 does not produce frame 1.");
            Assert.AreEqual(2, target.GetFrameIndex(0, Direction.EAST, NoLengthChecks: true), "EAST:0 does not produce frame 2.");
            Assert.AreEqual(3, target.GetFrameIndex(0, Direction.WEST, NoLengthChecks: true), "WEST:0 does not produce frame 3.");
        }
Exemplo n.º 20
0
        public static void PreloadStateContent(IconState state, string contentManagerName)
        {
            ContentManagerName = contentManagerName;
            switch (state)
            {
            case  IconState.Selected:
                break;

            case  IconState.NotSelected:
                break;
            }
        }
Exemplo n.º 21
0
        public void StopStateInterpolation(IconState stateToStop)
        {
            switch (stateToStop)
            {
            case  IconState.Selected:
                break;

            case  IconState.NotSelected:
                break;
            }
            CurrentIconStateState = stateToStop;
        }
Exemplo n.º 22
0
 /// The minimal preparation for use. If these are not set ShowChildLayer() can't work.
 public void Initialize(ConstellationMenuRoot root, AssetTree.Node asset, float scale)
 {
     menuRoot = root;
     menuRoot.MarkGraphDirty();
     menuNode            = asset;
     menuScale           = scale;
     menuOrientation     = transform.rotation;
     menuCenter          = transform.position;
     startPosition       = transform.position;
     savedCameraPosition = Camera.main.transform.position;
     savedCameraRotation = Camera.main.transform.rotation;
     state = IconState.Shown;
 }
Exemplo n.º 23
0
        private bool FadeChildren(IconState nextState)
        {
            bool stateChanged = false;

            foreach (ConstellationMenuIcon child in childMenus)
            {
                if (child.StartFade(nextState))
                {
                    stateChanged = true;
                }
            }
            return(stateChanged);
        }
Exemplo n.º 24
0
 /// Closes layers deeper than this. Shows sibling icons in the same layer.
 public void ShowThisLayer(IconState initialState)
 {
     if (parentMenu == null)
     {
         // The root icon has no siblings. Close everything.
         menuRoot.CloseAll();
     }
     else
     {
         FadeChildren(IconState.Closed);
         parentMenu.ShowChildLayer(initialState);
     }
 }
Exemplo n.º 25
0
 public override void Init(BaseScrollRect scrollRect)
 {
     base.Init(scrollRect);
     m_ScrollRect = scrollRect.GetComponent <ScrollRect>();
     m_ScrollBar  = m_ScrollRect.horizontalScrollbar;
     if (m_ScrollBar != null)
     {
         IconState m_IconState = m_ScrollBar.GetComponent <IconState>();
         if (m_IconState == null)
         {
             m_IconState = m_ScrollBar.gameObject.AddComponent <IconState>();
         }
     }
 }
Exemplo n.º 26
0
            public FadeParameters(IconState nextState, IconState prevState)
            {
                state = nextState;
                switch (state)
                {
                case IconState.Shown:
                    alpha = 1.0f;
                    if (prevState == IconState.Hovering)
                    {
                        duration = HOVER_ANIMATION_SECONDS;
                    }
                    else
                    {
                        duration = SHOW_ANIMATION_SECONDS;
                    }
                    buttonActive = true;
                    highlight    = 0.0f;
                    scale        = 1.0f;
                    zOffset      = SHOWING_Z_OFFSET;
                    break;

                case IconState.Hovering:
                    alpha        = 1.0f;
                    duration     = HOVER_ANIMATION_SECONDS;
                    buttonActive = true;
                    highlight    = 1.0f;
                    scale        = 1.0f;
                    zOffset      = HOVERING_Z_OFFSET;
                    break;

                case IconState.Hidden:
                    alpha        = 0.0f;
                    duration     = HIDE_ANIMATION_SECONDS;
                    buttonActive = false;
                    highlight    = 0.0f;
                    scale        = 1.5f;
                    zOffset      = HIDING_Z_OFFSET;
                    break;

                case IconState.Closed:
                    alpha        = 0.0f;
                    duration     = CLOSE_ANIMATION_SECONDS;
                    buttonActive = false;
                    highlight    = 0.0f;
                    scale        = 0.1f;
                    zOffset      = CLOSING_Z_OFFSET;
                    break;
                }
            }
Exemplo n.º 27
0
        public FlatRedBall.Instructions.Instruction InterpolateToState(IconState stateToInterpolateTo, double secondsToTake)
        {
            switch (stateToInterpolateTo)
            {
            case  IconState.Selected:
                break;

            case  IconState.NotSelected:
                break;
            }
            var instruction = new FlatRedBall.Instructions.DelegateInstruction <IconState>(StopStateInterpolation, stateToInterpolateTo);

            instruction.TimeToExecute = FlatRedBall.TimeManager.CurrentTime + secondsToTake;
            this.Instructions.Add(instruction);
            return(instruction);
        }
Exemplo n.º 28
0
        /*
         * Methods
         * */
        public override void DrawGUI(object sender)
        {
            this.windowID = this.windowBaseID;

            if (!this.modulesLoaded)
            {
                this.LoadModulesOfType <IVOID_Module>();

                FireOnModulesLoaded(this);
            }

            if (!this.skinsLoaded)
            {
                this.LoadSkins();
            }

            GUI.skin = this.Skin;

            if (!this.GUIStylesLoaded)
            {
                this.LoadGUIStyles();

                Logging.PostDebugMessage(
                    this,
                    "ToolbarAvailable: {0}, UseToobarManager: {1}",
                    ToolbarManager.ToolbarAvailable,
                    this.useToolbarManager);
            }

            if (
                this.iconState != (this.powerState | this.activeState) ||
                (this.VOIDIconTexture == null && this.AppLauncherButton != null)
                )
            {
                this.iconState = this.powerState | this.activeState;

                this.SetIconTexture(this.iconState);
            }

            if (this.Active)
            {
                base.DrawGUI(sender);
            }
        }
Exemplo n.º 29
0
        private bool StartFade(IconState nextState)
        {
            if (state == nextState)
            {
                return(false);
            }

            if (nextState == IconState.Closed && childMenus.Count > 0)
            {
                FadeChildren(IconState.Closed);
            }
            state          = nextState;
            fadeInProgress = true;

            if (nextState == IconState.Closed)
            {
                menuRoot.MarkGraphDirty();
            }

            fadeParameters = new FadeParameters(nextState);

            buttonActive = fadeParameters.buttonActive;
            SetColliderSize(Mathf.Min(boxCollider.size.x, fadeParameters.colliderSize));

            menuRoot.StartFadeOnIcon(this, nextState);
            ConstellationMenuIcon hoverIcon = (menuRoot == null) ? null : menuRoot.GetHoverIcon();
            // Change the background based on the relationship between this icon and the hoverIcon
            var relationship = GetRelationship(hoverIcon);

            tooltipAlpha.FadeTo(GetTooltipAlpha(relationship),
                                ANIMATION_DURATION_SECONDS, Time.time);
            iconBgAlpha.FadeTo(GetBackgroundAlpha(relationship),
                               ANIMATION_DURATION_SECONDS,
                               Time.time);
            decorationLabelAlpha.FadeTo(GetDecorationLabelAlpha(relationship),
                                        ANIMATION_DURATION_SECONDS, Time.time);
            iconScale.FadeTo(SHOWN_ICON_SCALE,
                             ANIMATION_DURATION_SECONDS,
                             Time.time);
            iconAlpha.FadeTo(fadeParameters.alpha,
                             ANIMATION_DURATION_SECONDS,
                             Time.time);
            return(true);
        }
Exemplo n.º 30
0
        public SparkleStatusIconController()
        {
            Program.Controller.FolderListChanged += delegate {
                if (UpdateMenuEvent != null)
                {
                    UpdateMenuEvent(CurrentState);
                }
            };


            Program.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error)
                {
                    CurrentState = IconState.Idle;
                }

                if (UpdateMenuEvent != null)
                {
                    UpdateMenuEvent(CurrentState);
                }
            };


            Program.Controller.OnSyncing += delegate {
                CurrentState = IconState.Syncing;

                if (UpdateMenuEvent != null)
                {
                    UpdateMenuEvent(IconState.Syncing);
                }
            };


            Program.Controller.OnError += delegate {
                CurrentState = IconState.Error;

                if (UpdateMenuEvent != null)
                {
                    UpdateMenuEvent(IconState.Error);
                }
            };
        }
Exemplo n.º 31
0
    public void SetIconState(IconState state)
    {
        m_IconSelected.style.visibility = Visibility.Hidden;
        m_IconActive.style.visibility   = Visibility.Hidden;
        m_IconDisabled.style.visibility = Visibility.Hidden;
        switch (state)
        {
        case IconState.Selected:
            m_IconSelected.style.visibility = Visibility.Visible;
            break;

        case IconState.Active:
            m_IconActive.style.visibility = Visibility.Visible;
            break;

        case IconState.Disabled:
            m_IconDisabled.style.visibility = Visibility.Visible;
            break;
        }
    }
Exemplo n.º 32
0
        /*
         * Methods
         * */
        public override void DrawGUI(object sender)
        {
            this.windowID = this.windowBaseID;

            if (!this.modulesLoaded)
            {
                this.LoadModulesOfType <IVOID_Module>();

                FireOnModulesLoaded(this);
            }

            if (!this.skinsLoaded)
            {
                this.LoadSkins();
            }
            else
            {
                GUI.skin = this.Skin;
            }

            if (!this.GUIStylesLoaded)
            {
                this.LoadGUIStyles();
            }

            if (
                this.iconState != (this.powerState | this.activeState) ||
                (this.VOIDIconTexture == null /*  && this.AppLauncherButton != null */)
                )
            {
                this.iconState = this.powerState | this.activeState;

                this.SetIconTexture(this.iconState);
            }

            if (this.Active)
            {
                base.DrawGUI(sender);
            }
        }
        public SparkleStatusIconController()
        {
            SparkleShare.Controller.FolderSizeChanged += delegate {
                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (CurrentState);
            };

            SparkleShare.Controller.FolderListChanged += delegate {
                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (CurrentState);
            };

            SparkleShare.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error)
                    CurrentState = IconState.Idle;

                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (CurrentState);
            };

            SparkleShare.Controller.OnSyncing += delegate {
                CurrentState = IconState.Syncing;

                // TODO up down both

                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (IconState.Syncing);
            };

            SparkleShare.Controller.OnError += delegate {
                CurrentState = IconState.Error;

                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (IconState.Error);
            };
        }
        public SparkleStatusIconController()
        {
            Program.Controller.FolderListChanged += delegate {
                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error)
                    CurrentState = IconState.Idle;

                if (UpdateQuitItemEvent != null)
                    UpdateQuitItemEvent (QuitItemEnabled);

                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnSyncing += delegate {
                int repos_syncing_up   = 0;
                int repos_syncing_down = 0;

                foreach (SparkleRepoBase repo in
                         Program.Controller.Repositories.GetRange (
                         	0, Program.Controller.Repositories.Count)) {

                    if (repo.Status == SyncStatus.SyncUp)
                        repos_syncing_up++;

                    if (repo.Status == SyncStatus.SyncDown)
                        repos_syncing_down++;
                }

                if (repos_syncing_up > 0 &&
                    repos_syncing_down > 0) {

                    CurrentState = IconState.Syncing;

                } else if (repos_syncing_down == 0) {
                    CurrentState = IconState.SyncingUp;

                } else {
                    CurrentState = IconState.SyncingDown;
                }

                if (UpdateQuitItemEvent != null)
                    UpdateQuitItemEvent (QuitItemEnabled);

                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnError += delegate {
                CurrentState = IconState.Error;

                if (UpdateQuitItemEvent != null)
                    UpdateQuitItemEvent (QuitItemEnabled);

                if (UpdateMenuEvent != null)
                    UpdateMenuEvent (CurrentState);
            };
        }
Exemplo n.º 35
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public StatusIconController ()
        {
            InitAnimation ();

            // A remote folder has been added.
            Program.Controller.FolderListChanged += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0)
                        StateText = Properties_Resources.ResourceManager.GetString("Welcome", CultureInfo.CurrentCulture);
                    else
                        StateText = Properties_Resources.ResourceManager.GetString("FilesUpToDate", CultureInfo.CurrentCulture);
                }

                UpdateStatusItemEvent (StateText);
                UpdateMenuEvent (CurrentState);
            };

            // No more download/upload.
            Program.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0)
                        StateText = Properties_Resources.ResourceManager.GetString("Welcome", CultureInfo.CurrentCulture);
                    else
                        StateText = Properties_Resources.ResourceManager.GetString("FilesUpToDate", CultureInfo.CurrentCulture);
                }

                UpdateStatusItemEvent (StateText);

                this.animation.Stop ();

                UpdateIconEvent (0);
                UpdateMenuEvent (CurrentState);
            };

            // Syncing.
            Program.Controller.OnSyncing += delegate {
				CurrentState = IconState.Syncing;
                StateText = Properties_Resources.ResourceManager.GetString("SyncingChanges", CultureInfo.CurrentCulture);

                UpdateStatusItemEvent (StateText);

                this.animation.Start ();
            };
        }
Exemplo n.º 36
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public StatusIconController()
        {
            InitAnimation();

            // A remote folder has been added.
            Program.Controller.FolderListChanged += delegate
            {
                if (CurrentState != IconState.Error)
                {
                    CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0)
                        StateText = Properties_Resources.Welcome;
                    else
                        StateText = Properties_Resources.FilesUpToDate;
                }

                UpdateStatusItemEvent(StateText);
                UpdateIconEvent(CurrentState == IconState.Error ? -1 : 0);
                UpdateMenuEvent(CurrentState);
            };

            // No more download/upload.
            Program.Controller.OnIdle += delegate
            {
                if (CurrentState != IconState.Error)
                {
                    CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0)
                        StateText = Properties_Resources.Welcome;
                    else
                        StateText = Properties_Resources.FilesUpToDate;
                }

                UpdateStatusItemEvent(StateText);

#if MonoBug24381
                //this.animation_frame_number = 0; // Idle status icon
                //UpdateIconEvent(this.animation_frame_number);
#else
                this.animation.Stop();
                UpdateIconEvent(CurrentState == IconState.Error ? -1 : 0);
#endif

                UpdateMenuEvent(CurrentState);
            };

            // Syncing.
            Program.Controller.OnSyncing += delegate
            {
                Logger.Debug("StatusIconController OnSyncing");
                CurrentState = IconState.Syncing;
                StateText = Properties_Resources.SyncingChanges;

                UpdateStatusItemEvent(StateText);

#if MonoBug24381
                //this.animation_frame_number = 3; // Syncing icon
                //UpdateIconEvent(this.animation_frame_number);
#else
                this.animation.Start();
#endif
            };

            // Error.
            Program.Controller.OnError += delegate(Tuple<string, Exception> error)
            {
                //FIXME: why a Tuple? We should get delegate(ErrorEvent event) or delegate(string repoName, Exception error)
                String reponame = error.Item1;
                Exception exception = error.Item2;

                Logger.Error(String.Format("Error syncing '{0}': {1}", reponame, exception.Message), exception);

                string message = String.Format(Properties_Resources.SyncError, reponame, exception.Message);

                IconState PreviousState = CurrentState;
                CurrentState = IconState.Error;
                StateText = message;

                UpdateStatusItemEvent(StateText);

#if ! MonoBug24381
                this.animation.Stop();

                UpdateIconEvent(-1);
                UpdateMenuEvent(CurrentState);
#endif

                if (exception is PermissionDeniedException)
                {
                    //FIXME: why it get suspended? Instead i should ask the user if the password has changed and he want to enter a new one
                    //Suspend sync...
                    SuspendSyncClicked(reponame);
                }

                if (PreviousState != IconState.Error)
                {
                    Program.Controller.ShowAlert(Properties_Resources.Error, message);
                }
            };

            Program.Controller.OnErrorResolved += delegate
            {
                CurrentState = IconState.Idle;
            };
        }
Exemplo n.º 37
0
        public IconController () : base ()
        {
            recentChanges = new List<NSMenuItem> ();
            using (var a = new NSAutoreleasePool ()) {
                this.status_item = NSStatusBar.SystemStatusBar.CreateStatusItem (28);
                this.status_item.HighlightMode = true;


                this.syncing_working = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-working.png"));
                this.syncing_idle_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-idle.png"));
                this.syncing_up_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-up.png"));
                this.syncing_down_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-down.png"));
                this.syncing_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing.png"));
                this.syncing_error_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-error.png"));
                this.disconnected_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-active_new.png"));

                this.syncing_idle_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-idle-active.png"));
                this.syncing_up_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-up-active.png"));
                this.syncing_down_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-down-active.png"));
                this.syncing_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-active.png"));
                this.syncing_error_image_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-syncing-error-active.png"));
                this.sync_pause_active = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "process-paused.png"));
    
                this.status_item.Image = this.syncing_working;
                this.status_item.Image.Size = new SizeF (16, 16);

                //this.status_item.AlternateImage      = this.syncing_idle_image_active;
                //this.status_item.AlternateImage.Size = new SizeF (16, 16);
                this.folder_image = NSImage.ImageNamed ("NSFolder");
                this.caution_image = NSImage.ImageNamed ("NSCaution");
                this.sparkleshare_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "qloudsync-folder.icns"));

                this.share_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "share.png"));
                this.docs_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "folder-docs.png"));
                this.docs_image.Size = new SizeF (16, 16);
                this.movies_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "folder-movies.png"));
                this.movies_image.Size = new SizeF (16, 16);
                this.music_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "folder-music.png"));
                this.music_image.Size = new SizeF (16, 16);
                this.pics_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "folder-pics.png"));
                this.pics_image.Size = new SizeF (16, 16);
                this.default_image = new NSImage (Path.Combine (NSBundle.MainBundle.ResourcePath, "Pixmaps", "file-3.png"));
                this.default_image.Size = new SizeF (16, 16);

                CreateMenu ();
            }


            Program.Controller.OnIdle += delegate {
                    CurrentState = IconState.Idle;
                    StateText = "✓  Up to date ";
                    UpdateQuitItemEvent (QuitItemEnabled);
                    UpdateStatusItemEvent (StateText, this.up_to_date);
                    UpdateIconEvent (CurrentState);
                    CreateMenu();
            };

            Program.Controller.OnPaused += delegate {
                    CurrentState = IconState.Paused;
                    StateText = "Sync Paused ";
                    isPaused = true;
                    UpdateQuitItemEvent (QuitItemEnabled);
                    UpdateStatusItemEvent (StateText, this.up_to_date);
                    UpdateIconEvent (CurrentState);
                    CreateMenu();
            }; 

            Program.Controller.OnSyncing += delegate {
           
                    isPaused = false;

                    bool syncDown = SynchronizerUnit.AnyDownloading (); 
                    bool syncUp = SynchronizerUnit.AnyUploading (); 

                    if (syncDown && syncUp) {
                        CurrentState = IconState.Syncing;
                        StateText = "⟳ Syncing changes…";
                        
                    } else if (syncUp) {
                        CurrentState = IconState.SyncingUp;
                        StateText = "⟳ Sending changes…";
                        
                    } else if (syncDown) {
                        CurrentState = IconState.SyncingDown;
                        StateText = "⟳ Receiving changes…";
                    } else {
                        CurrentState = IconState.Idle;
                        StateText = "✓  Up to date ";
                    }

                    UpdateIconEvent (CurrentState);
                    UpdateStatusItemEvent (StateText, this.syncing_working);
                    UpdateQuitItemEvent (QuitItemEnabled);
                    CreateMenu();

            };
            
            Program.Controller.OnError += delegate {
             
                    isPaused = false;
                    CurrentState = IconState.Error;
                    switch (Program.Controller.ErrorType) {
                    case Controller.ERROR_TYPE.DISCONNECTION:
                        StateText = "✗   Lost network connection";
                        break;
                    case Controller.ERROR_TYPE.ACCESS_DENIED:
                        StateText = "✗   Access Denied. Login again!";
                        this.preferences_item.Enabled = true;
                        break;
                    default:
                        StateText = "✗   Failed to send some changes";
                        break;
                    }
                    UpdateQuitItemEvent (QuitItemEnabled);
                    UpdateStatusItemEvent (StateText, this.error_in_sync);
                    UpdateIconEvent (CurrentState);
                    CreateMenu();
                
            };			

            UpdateIconEvent += delegate (IconState state) {
                using (var a = new NSAutoreleasePool ()) {
                    NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                        switch (state) {
                        case IconState.Idle:
                            {
                                this.status_item.Image = this.syncing_idle_image;
                                break;
                            }
                        case IconState.SyncingUp:
                            {
                                this.status_item.Image = this.syncing_up_image;
                                break;
                            }
                        case IconState.SyncingDown:
                            {
                                this.status_item.Image = this.syncing_down_image;
                                break;
                            }
                        case IconState.Syncing:
                            {
                                this.status_item.Image = this.syncing_image;
                                break;
                            }
                        case IconState.Error:
                            {
                                if (Program.Controller.ErrorType == Controller.ERROR_TYPE.DISCONNECTION) {
                                    this.status_item.Image = this.disconnected_image;
                                } else {
                                    this.status_item.Image = this.syncing_error_image;
                                }
                                break;
                            }
                        case IconState.Paused:
                            {
                                this.status_item.Image = this.sync_pause_active;
                                break;
                            }
                        }

                        this.status_item.Image.Size = new SizeF (16, 16);
                    });
                }
            };

            UpdateStatusItemEvent += delegate (string state_text, NSImage image) {
                using (var a = new NSAutoreleasePool ()) {
                    NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                        StateText = state_text;
                    });
                }
            };

            UpdateQuitItemEvent += delegate (bool quit_item_enabled) {
                using (var a = new NSAutoreleasePool ()) {
                    NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                        this.quit_item.Enabled = quit_item_enabled;
                    });
                }
            };
        }
        public SparkleStatusIconController ()
        {
            UpdateFolders ();

            Program.Controller.FolderListChanged += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    if (Folders.Length == 0)
                        StateText = "Welcome to SparkleShare!";
                    else
                        StateText = "Projects up to date " + FolderSize;
                }

                UpdateFolders ();

                UpdateStatusItemEvent (StateText);
                UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    if (Folders.Length == 0)
                        StateText = "Welcome to SparkleShare!";
                    else
                        StateText = "Projects up to date " + FolderSize;
                }

                UpdateFolders ();

                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
                UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnSyncing += delegate {
				int repos_syncing_up   = 0;
				int repos_syncing_down = 0;
				
				foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
					if (repo.Status == SyncStatus.SyncUp)
						repos_syncing_up++;
					
					if (repo.Status == SyncStatus.SyncDown)
						repos_syncing_down++;
				}
				
				if (repos_syncing_up > 0 &&
				    repos_syncing_down > 0) {
					
					CurrentState = IconState.Syncing;
                    StateText    = "Syncing changes…";
				
				} else if (repos_syncing_down == 0) {
					CurrentState = IconState.SyncingUp;
                    StateText    = "Sending changes…";
					
				} else {
					CurrentState = IconState.SyncingDown;
                    StateText    = "Receiving changes…";
				}

                if (ProgressPercentage > 0)
                    StateText += " " + ProgressPercentage + "%  " + ProgressSpeed;

                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
                UpdateQuitItemEvent (QuitItemEnabled);
            };

            Program.Controller.OnError += delegate {
                CurrentState = IconState.Error;
                StateText    = "Failed to send some changes";

                UpdateFolders ();
                
                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
                UpdateMenuEvent (CurrentState);
            };


            // FIXME: Hack to work around a race condition causing
            // the icon to not always show the right state
            Timers.Timer timer = new Timers.Timer () { Interval = 30 * 1000 };

            timer.Elapsed += delegate {
                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
            };

            timer.Start ();
        }
Exemplo n.º 39
0
 public void ChangeState(IconState state)
 {
     if (state == IconState.LOAD)
     {
         nIcon.Icon = ScreenShot.Properties.Resources.load;
         nIcon.Text = "Envoi des données..";
     }
     else if (state == IconState.READY)
     {
         nIcon.Icon = ScreenShot.Properties.Resources.check;
         nIcon.Text = "Prêt !";
     }
     else if (state == IconState.STOP)
     {
         nIcon.Icon = ScreenShot.Properties.Resources.stop;
         nIcon.Text = "Le serveur ne répond pas.";
     }
     else if (state == IconState.ERROR)
     {
         nIcon.Icon = ScreenShot.Properties.Resources.error;
         nIcon.Text = "Erreur";
     }
 }
        public PryanetStatusIconController ()
        {
            UpdateFolders ();

            Program.Controller.FolderListChanged += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    if (Folders.Length == 0)
                        StateText = "Welcome to PryanetShare!";
                    else
                        StateText = "Projects up to date " + FolderSize;
                }

                UpdateFolders ();

                UpdateStatusItemEvent (StateText);
                UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    if (Folders.Length == 0)
                        StateText = "Welcome to PryanetShare!";
                    else
                        StateText = "Projects up to date " + FolderSize;
                }

                UpdateFolders ();

                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
                UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnSyncing += delegate {
				int repos_syncing_up   = 0;
				int repos_syncing_down = 0;
				
				foreach (PryanetRepoBase repo in Program.Controller.Repositories) {
					if (repo.Status == SyncStatus.SyncUp)
						repos_syncing_up++;
					
					if (repo.Status == SyncStatus.SyncDown)
						repos_syncing_down++;
				}
				
				if (repos_syncing_up > 0 &&
				    repos_syncing_down > 0) {
					
					CurrentState = IconState.Syncing;
                    StateText    = "Syncing changes…";
				
				} else if (repos_syncing_down == 0) {
					CurrentState = IconState.SyncingUp;
                    StateText    = "Sending changes…";
					
				} else {
					CurrentState = IconState.SyncingDown;
                    StateText    = "Receiving changes…";
				}

                if (ProgressPercentage > 0)
                    StateText += " " + ProgressPercentage + "%  " + ProgressSpeed;

                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
                UpdateQuitItemEvent (QuitItemEnabled);
            };

            Program.Controller.OnError += delegate {
                CurrentState = IconState.Error;
                StateText    = "Failed to send some changes";

                UpdateFolders ();
                
                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
                UpdateMenuEvent (CurrentState);
            };
        }
Exemplo n.º 41
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public StatusIconController ()
        {
            InitAnimation ();

            // A remote folder has been added.
            Program.Controller.FolderListChanged += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0)
                        StateText = Properties_Resources.Welcome;
                    else
                        StateText = Properties_Resources.FilesUpToDate;
                }

                UpdateStatusItemEvent (StateText);
                UpdateIconEvent(CurrentState == IconState.Error ? -1 : 0);
                UpdateMenuEvent(CurrentState);
            };

            // No more download/upload.
            Program.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0)
                        StateText = Properties_Resources.Welcome;
                    else
                        StateText = Properties_Resources.FilesUpToDate;
                }

                UpdateStatusItemEvent (StateText);

                this.animation.Stop ();

                UpdateIconEvent(CurrentState == IconState.Error ? -1 : 0);
                UpdateMenuEvent (CurrentState);
            };

            // Syncing.
            Program.Controller.OnSyncing += delegate {
                CurrentState = IconState.Syncing;
                StateText = Properties_Resources.SyncingChanges;

                UpdateStatusItemEvent (StateText);

                this.animation.Start ();
            };


            // Error.
            Program.Controller.OnError += delegate (Tuple<string, Exception> error)
            {
                Logger.Error(String.Format("Error syncing '{0}': {1}", error.Item1, error.Item2.Message), error.Item2);

                string message = String.Format(Properties_Resources.SyncError, error.Item1, error.Item2.Message);

                CurrentState = IconState.Error;
                StateText = message;

                UpdateStatusItemEvent(StateText);

                this.animation.Stop();

                UpdateIconEvent(-1);
                UpdateMenuEvent(CurrentState);

                if (error.Item2 is PermissionDeniedException)
                {
                    //Suspend sync...
                    SuspendSyncClicked(error.Item1);
                }

                Program.Controller.ShowAlert(Properties_Resources.Error, message);
            };

            Program.Controller.OnErrorResolved += delegate
            {
                CurrentState = IconState.Idle;
            };
        }
        public SparkleStatusIconController ()
        {
            InitAnimation ();

            Program.Controller.FolderListChanged += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0)
                        StateText = "Welcome to CmisSync!";
                    else
                        StateText = "Files up to date " + FolderSize;
                }

                UpdateStatusItemEvent (StateText);
                UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0)
                        StateText = "Welcome to CmisSync!";
                    else
                        StateText = "Files up to date " + FolderSize;
                }

                UpdateQuitItemEvent (QuitItemEnabled);
                UpdateStatusItemEvent (StateText);

                this.animation.Stop ();

                UpdateIconEvent (0);
                UpdateMenuEvent (CurrentState);
            };

            Program.Controller.OnSyncing += delegate {
				int repos_syncing_up   = 0;
				int repos_syncing_down = 0;
				
				foreach (SparkleRepoBase repo in Program.Controller.Repositories) {
					if (repo.Status == SyncStatus.SyncUp)
						repos_syncing_up++;
					
					if (repo.Status == SyncStatus.SyncDown)
						repos_syncing_down++;
				}
				
				if (repos_syncing_up > 0 &&
				    repos_syncing_down > 0) {
					
					CurrentState = IconState.Syncing;
                    StateText    = "Syncing changes…";
				
				} else if (repos_syncing_down == 0) {
					CurrentState = IconState.SyncingUp;
                    StateText    = "Sending changes…";
					
				} else {
					CurrentState = IconState.SyncingDown;
                    StateText    = "Receiving changes…";
				}

                StateText += " " + ProgressPercentage + "%  " + ProgressSpeed;

                UpdateStatusItemEvent (StateText);
                UpdateQuitItemEvent (QuitItemEnabled);

                this.animation.Start ();
            };

            Program.Controller.OnError += delegate {
                CurrentState = IconState.Error;
                StateText    = "Failed to send some changes";

                UpdateQuitItemEvent (QuitItemEnabled);
                UpdateStatusItemEvent (StateText);

                this.animation.Stop ();

                UpdateIconEvent (-1);
            };
        }
Exemplo n.º 43
0
        public StatusIconController ()
        {
            UpdateFolders ();

            SparkleShare.Controller.FolderListChanged += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;

                    UpdateStateText ();
                }

                UpdateFolders ();

                UpdateStatusItemEvent (StateText);
                UpdateMenuEvent (CurrentState);
            };

            SparkleShare.Controller.OnIdle += delegate {
                if (CurrentState != IconState.Error) {
                    CurrentState = IconState.Idle;
                    UpdateStateText ();
                }

                UpdateFolders ();

                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
                UpdateQuitItemEvent (QuitItemEnabled);
                UpdateMenuEvent (CurrentState);
            };

            SparkleShare.Controller.OnSyncing += delegate {
                int repos_syncing_up = 0;
                int repos_syncing_down = 0;

                foreach (BaseRepository repo in SparkleShare.Controller.Repositories) {
                    if (repo.Status == SyncStatus.SyncUp)
                        repos_syncing_up++;

                    if (repo.Status == SyncStatus.SyncDown)
                        repos_syncing_down++;
                }

                if (repos_syncing_up > 0 &&
                    repos_syncing_down > 0) {

                    CurrentState = IconState.Syncing;
                    StateText    = "Syncing…";

                } else if (repos_syncing_down == 0) {
                    CurrentState = IconState.SyncingUp;
                    StateText    = "Sending…";

                } else {
                    CurrentState = IconState.SyncingDown;
                    StateText    = "Receiving…";
                }

                int progress_percentage = (int) SparkleShare.Controller.ProgressPercentage;
                string progress_speed = "";

                if (SparkleShare.Controller.ProgressSpeedUp > 0.0 && SparkleShare.Controller.ProgressSpeedDown > 0.0) {
                    progress_speed = "Up: " + SparkleShare.Controller.ProgressSpeedUp.ToSize () + "/s " +
                        "Down: " + SparkleShare.Controller.ProgressSpeedDown.ToSize () + "/s";
                }

                if (SparkleShare.Controller.ProgressSpeedUp > 0.0)
                    progress_speed = SparkleShare.Controller.ProgressSpeedUp.ToSize () + "/s ";

                if (SparkleShare.Controller.ProgressSpeedDown > 0.0)
                    progress_speed = SparkleShare.Controller.ProgressSpeedDown.ToSize () + "/s ";

                if (progress_percentage > 0)
                    StateText += string.Format (" {0}% {1}", progress_percentage, progress_speed);

                if (!string.IsNullOrEmpty (SparkleShare.Controller.ProgressInformation))
                    StateText += " – " + SparkleShare.Controller.ProgressInformation;

                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
                UpdateQuitItemEvent (QuitItemEnabled);
            };

            SparkleShare.Controller.OnError += delegate {
                CurrentState = IconState.Error;
                StateText = "Not everything synced";

                UpdateFolders ();
                
                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
                UpdateQuitItemEvent (QuitItemEnabled);
                UpdateMenuEvent (CurrentState);
            };


            // FIXME: Work around a race condition causing
            // the icon to not always show the right state
            var timer = new Timers.Timer { Interval = 30 * 1000 };

            timer.Elapsed += delegate {
                UpdateIconEvent (CurrentState);
                UpdateStatusItemEvent (StateText);
            };

            timer.Start ();
        }
Exemplo n.º 44
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public StatusIconController() {
            this.InitAnimation();

            // A remote folder has been added.
            Program.Controller.FolderListChanged += delegate {
                if (this.CurrentState != IconState.Error) {
                    this.CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0) {
                        this.StateText = string.Format(Properties_Resources.Welcome, Properties_Resources.ApplicationName);
                    } else {
                        this.StateText = Properties_Resources.StatusNoChangeDetected;
                    }
                }

                this.UpdateStatusItemEvent(this.StateText);
                this.UpdateMenuEvent(this.CurrentState);
            };

            // No more download/upload.
            Program.Controller.OnIdle += delegate {
                if (this.CurrentState != IconState.Error) {
                    this.CurrentState = IconState.Idle;

                    if (Program.Controller.Folders.Count == 0) {
                        this.StateText = string.Format(Properties_Resources.Welcome, Properties_Resources.ApplicationName);
                    } else {
                        this.StateText = Properties_Resources.StatusNoChangeDetected;
                    }
                }

                this.UpdateStatusItemEvent(this.StateText);
            };

            Program.Controller.OnTransmissionListChanged += delegate {
                this.UpdateTransmissionMenuEvent();
            };

            // Syncing.
            Program.Controller.OnSyncing += delegate {
                if (this.CurrentState != IconState.Syncing) {
                    this.CurrentState = IconState.Syncing;
                    this.StateText = Properties_Resources.SyncingChanges;
                    this.UpdateStatusItemEvent(this.StateText);
                    if (!this.animation.Enabled) {
                        this.animation.Start();
                    }
                }
            };

            // Paused.
            Program.Controller.OnPaused += delegate {
                if (this.CurrentState != IconState.Error) {
                    this.CurrentState = IconState.Paused;
                    this.StateText = Properties_Resources.SyncStatusPaused;
                }

                this.UpdateStatusItemEvent(this.StateText);
            };

            // Deactivated.
            Program.Controller.OnDeactivated += delegate {
                if (this.CurrentState != IconState.Error) {
                    this.CurrentState = IconState.Deactivated;
                    this.StateText = Properties_Resources.SyncStatusDeactivated;
                }

                this.UpdateStatusItemEvent(this.StateText);
            };

            // Disconnected.
            Program.Controller.OnDisconnected += delegate {
                if (this.CurrentState != IconState.Error) {
                    this.CurrentState = IconState.Disconnected;
                    this.StateText = Properties_Resources.SyncStatusDisconnected;
                }

                this.UpdateStatusItemEvent(this.StateText);
            };
        }