Exemplo n.º 1
0
        private void UpdateTask(TaskData td)
        {
            if (td.Id < TaskList.Count) // 判断存在,存在就不用再克隆了
            {
                return;
            }
            // 克隆UI
            GameObject go = Instantiate(TaskPrefab);

            go.transform.parent = TaskRectTransform;
            go.SetActive(true);
            UiTask ut = new UiTask(go);

            TaskList.Add(ut);
            ut.Id         = td.Id;
            ut.Place.text = Tasks[td.Id].TaskPlace;
            ut.Name.text  = Tasks[td.Id].TaskName;
            ut.Award.text = Tasks[td.Id].TaskAward.ToString();
            AddBattleListener(td.Id, ut.Battle);
            // 完成情况
            if (td.HasCompletedRank3)
            {
                ut.Complete.color = AcColor;
            }
            else if (td.HasCompleted)
            {
                ut.Complete.color = CompleteColor;
            }
            else
            {
                ut.Complete.color = UnCompleteColor;
            }
        }
Exemplo n.º 2
0
        void IItemsConsumer.Removed(object item)
        {
            lock (_recalcLock)
            {
                _recalculate = true;
            }

            UiView view = null;

            lock (_childrenLock)
            {
                if (_bindingToElement.TryGetValue(item, out view))
                {
                    _bindingToElement.Remove(item);
                }
            }

            if (view != null)
            {
                UiTask.BeginInvoke(() =>
                {
                    view.ViewRemoved();
                    _children.Remove(view);
                });
            }
        }
Exemplo n.º 3
0
        public void ReloadServerItem(IPEndPoint iPEndPoint, CancellationToken cancellationToken)
        {
            var dest = ServerItems;

            try
            {
                UiTask.Run(() => dest.Clear(), cancellationToken).Wait(cancellationToken);
            }

            catch (OperationCanceledException)
            {
                Trace.WriteLine("Reloading canceled");
                return;
            }

            var vo = _defaultServerRepository.GetServerInfo(new IPEndPoint(iPEndPoint.Address, iPEndPoint.Port + 1));

            if (cancellationToken.IsCancellationRequested || vo == null)
            {
                return;
            }
            var item = new ServerItem();

            AssignProperties(item, vo);

            UiTask.Run((dest2, item2) => dest2.Add(item2), dest, item).Wait(0);
        }
Exemplo n.º 4
0
        //internal void TestJson()
        //{
        //    _context.TestJson();
        //}

        private async void EndlessRefreshSelecteItem()
        {
            while (true)
            {
                var mainwin = await UiTask.Run(() => App.Current.MainWindow);

                if (mainwin == null)
                {
                    break;
                }
                try
                {
                    var task = UiTask.Run(() => mainwin.WindowState != WindowState.Minimized);
                    task.Wait();
                    if (task.IsCompleted && task.Result && !_isJoining)
                    {
                        var item = SelectedServerItem;
                        if (item != null)
                        {
                            _context.RefreshServerInfo(new[] { item });
                        }
                    }
                    await Task.Delay(3000);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 5
0
 public override void TouchesMoved(NSSet touches, UIEvent evt)
 {
     OnTouch(touches, (position, id, handle) =>
     {
         UiTask.BeginInvoke(() => TouchPad.Instance.ProcessMove(id, position, DateTime.Now));
     });
 }
Exemplo n.º 6
0
        public void OnNew(string template)
        {
            if (!Document.Current.IsModified)
            {
                ChangeTemplate(template);
                Document.Instance.New();
                HideElement("FileMenu");
                return;
            }

            MessageBox.YesNoCancel(SaveChangesQuestion,
                                   () =>
            {
                UiTask.BeginInvoke(() =>
                {
                    if (SaveInternal())
                    {
                        ChangeTemplate(template);
                        Document.Instance.New();
                    }
                });
            },
                                   () =>
            {
                ChangeTemplate(template);
                Document.Instance.New();
            },
                                   () =>
            {
                HideElement("FileMenu");
            });
        }
Exemplo n.º 7
0
        protected override void Draw(ref UiViewDrawParameters parameters)
        {
            float opacity = parameters.Opacity;

            if (opacity == 0)
            {
                return;
            }

            DrawBackground(ref parameters);

            UiViewDrawParameters drawParams = parameters;

            drawParams.Opacity             = opacity;
            drawParams.Transition          = 1 - DisplayVisibility;
            drawParams.TransitionRectangle = ScreenBounds;

            drawParams.TransitionMode = DisplayVisibility == 1 ? TransitionMode.None : (Visible ? TransitionMode.Show : TransitionMode.Hide);

            if (DisplayVisibility == 1 && !_alreadyFullyVisible)
            {
                _alreadyFullyVisible = true;

                UiTask.BeginInvoke(() => CallDelegate("PageShown"));
            }

            for (int idx = 0; idx < _children.Count; ++idx)
            {
                _children[idx].ViewDraw(ref drawParams);
            }
        }
Exemplo n.º 8
0
 void Window_DidResize(object sender, EventArgs e)
 {
     UiTask.BeginInvoke(() =>
     {
         GameController.UpdateScale(_appMain);
         _appMain.SizeChanged();
     });
 }
Exemplo n.º 9
0
 static void Window_ClientSizeChanged(object sender, EventArgs e)
 {
     UiTask.BeginInvoke(() =>
     {
         GameController.UpdateScale(AppMain.Current);
         AppMain.Current.SizeChanged();
     });
 }
Exemplo n.º 10
0
 void _image_ValueChanged(Texture2D newValue)
 {
     UiTask.BeginInvoke(() =>
     {
         SetForceRecalcFlag();
         Parent.RecalcLayout();
     });
 }
Exemplo n.º 11
0
        //public void TestJson()
        //{
        //    _defaultBrowserServerRepository.Test();
        //}

        private void ps_Exited(object sender, EventArgs e)
        {
            //Todo Move to ViewModel Code
            var t = UiTask.Run(() =>
            {
                Application.Current.MainWindow.WindowState = WindowState.Normal;
                Application.Current.MainWindow.Activate();
            });
        }
Exemplo n.º 12
0
        void _expanded_ValueChanged(bool newValue)
        {
            UiTask.BeginInvoke(() => ForceUpdate());

            if (newValue)
            {
                CallDelegate("ExpandStarted");
            }
        }
Exemplo n.º 13
0
        void IItemsConsumer.RemovedAll()
        {
            lock (_childrenLock)
            {
                _children.Clear();
                _bindingToElement.Clear();
            }

            UiTask.BeginInvoke(() => RecalculateAll());
        }
Exemplo n.º 14
0
 public void DoActionWhenUnfocused(EmptyArgsVoidDelegate action)
 {
     if (!Focused)
     {
         action();
     }
     else
     {
         UiTask.BeginInvoke(() => DoActionWhenUnfocused(action));
     }
 }
Exemplo n.º 15
0
 protected void Text_ValueChanged()
 {
     if (Parent != null)
     {
         UiTask.BeginInvoke(() =>
         {
             SetForceRecalcFlag();
             Parent.RecalcLayout();
         });
     }
 }
Exemplo n.º 16
0
        static void Window_ClientSizeChanged(object sender, EventArgs e)
        {
            UiTask.BeginInvoke(() =>
            {
                double unit = Math.Min((double)AppMain.Current.GraphicsDevice.Viewport.Width / 640.0,
                                       (double)AppMain.Current.GraphicsDevice.Viewport.Height / 480.0);

                unit = Math.Min(1, unit);

                UiUnit.FontUnit = UiUnit.Unit = unit;
            });
        }
Exemplo n.º 17
0
        public void LockListener(int pointerId, object listener)
        {
            UiTask.BeginInvoke(() =>
            {
                _gesture.GestureType = GestureType.CapturedByOther;
                _gesture.TouchId     = pointerId;
                _gesture.ResetState();
                _gesture.CapturePointer(listener);

                OnGesture();
            });
        }
Exemplo n.º 18
0
        void NativeInput.ITextEdit.Return()
        {
            UiTask.BeginInvoke(() =>
            {
                object ret = CallDelegate("Return");

                if (!(ret is bool && (bool)ret))
                {
                    OnApply();
                    Unfocus();
                }
            });
        }
Exemplo n.º 19
0
        private void LoadingServerList(object loadingServerListContext)
        {
            var threadId = Thread.CurrentThread.ManagedThreadId;
            var state    = (LoadingServerListContext)loadingServerListContext;

            foreach (var dataItem in state.Ips)
            {
                if (state.Token.IsCancellationRequested)
                {
                    break;
                }

                var serverQueryEndpoint = new IPEndPoint(dataItem.Host, dataItem.QueryPort);

                if (LiveAction != null)
                {
                    LiveAction(this,
                               string.Format("{2,3} {0} {1}", BitConverter.ToString(dataItem.Host.GetAddressBytes()),
                                             BitConverter.ToString(BitConverter.GetBytes(dataItem.QueryPort)), threadId));
                }

                var vo = _defaultServerRepository.GetServerInfo(serverQueryEndpoint);

                if (state.Token.IsCancellationRequested)
                {
                    break;
                }

                var item = new ServerItem();
                if (vo != null)
                {
                    AssignProperties(item, vo);
                }
                else
                {
                    item.Name      = string.Format("{0}:{1}", serverQueryEndpoint.Address, serverQueryEndpoint.Port - 1);
                    item.Host      = serverQueryEndpoint.Address;
                    item.QueryPort = serverQueryEndpoint.Port;
                }

                state.ProgressValue++;
                state.Ping = item.Ping;

                var t = UiTask.Run((dest2, item2) => dest2.Add(item2), state.Dest, item);
            }
            state.Finished();
            Task.Delay(TimeSpan.FromSeconds(0.5))
            .ContinueWith((t, ctx) => ReloadThreads.Remove((LoadingServerListContext)ctx), state, UiTask.UiTaskScheduler)
            .Wait();
            //UiTask.Run(ctx => ReloadThreads.Remove(ctx), state).Wait();
        }
Exemplo n.º 20
0
        void IItemsConsumer.Removed(object item)
        {
            lock (_childrenLock)
            {
                UiView view;
                if (_bindingToElement.TryGetValue(item, out view))
                {
                    _children.Remove(view);
                    _bindingToElement.Remove(item);
                }
            }

            UiTask.BeginInvoke(() => RecalculateAll());
        }
Exemplo n.º 21
0
        void _expanded_ValueChanged(bool newValue)
        {
            UiTask.BeginInvoke(() =>
            {
                ForceUpdate();
                SetForceRecalcFlag();
                Parent.RecalcLayout();
            });

            if (newValue)
            {
                CallDelegate("ExpandStarted");
            }
        }
Exemplo n.º 22
0
        public void SaveAs()
        {
            UiTask.BeginInvoke(() =>
            {
                string path = Platform.SaveFileDialog("Save file", "Map file (*.smf)|*.smf|All files|*.*", ".smf");

                if (path != null)
                {
                    Document.Instance.Save(path);
                }

                HideElement("FileMenu");
            });
        }
Exemplo n.º 23
0
        void IItemsConsumer.RemovedAll()
        {
            lock (_childrenLock)
            {
                foreach (var child in _children)
                {
                    child.ViewRemoved();
                }
                _children.Clear();
                _bindingToElement.Clear();
            }

            UiTask.BeginInvoke(() => RecalculateAll());
        }
Exemplo n.º 24
0
        internal void AppDeactivated()
        {
            UiTask.BeginInvoke(() =>
            {
                foreach (var element in _elements)
                {
                    _gesture.TouchId = element.Key;
                    _gesture.ResetState();

                    OnGesture();
                }

                _elements.Clear();
            });
        }
Exemplo n.º 25
0
        public void Unfocus()
        {
            _textField.Visibility = Android.Views.ViewStates.Invisible;

            _textField.TextChanged  -= HandleEditingChanged;
            _textField.FocusChange  -= HandleFocusChange;
            _textField.EditorAction -= HandleEditorAction;

            UiTask.BeginInvoke(() =>
            {
                if (CurrentFocus == this)
                {
                    HideKeyboard(_textField);
                }
            });
        }
Exemplo n.º 26
0
        public ObservableCollection <PropNameValue> LoadPropertyData()
        {
            var listPropValue = new ObservableCollection <PropNameValue>();

            listPropValue.Add(new PropNameValue("Tag", Tag));
            listPropValue.Add(new PropNameValue("ClassName", ClassName));
            listPropValue.Add(new PropNameValue("Name", Name));
            listPropValue.Add(new PropNameValue("AutomationId", AutomationId));
            listPropValue.Add(new PropNameValue("Position", (Position ?? "").ToString()));
            listPropValue.Add(new PropNameValue("Left", (Left ?? "").ToString()));
            listPropValue.Add(new PropNameValue("Top", (Top ?? "").ToString()));
            listPropValue.Add(new PropNameValue("Width", (Width ?? "").ToString()));
            listPropValue.Add(new PropNameValue("Height", (Height ?? "").ToString()));
            listPropValue.Add(new PropNameValue("RuntimeId", RuntimeId));
            listPropValue.Add(new PropNameValue("UiTask", UiTask != null ? UiTask.ToString() : ""));
            return(listPropValue);
        }
Exemplo n.º 27
0
        void NativeInput.ITextEdit.LostFocus()
        {
            Focused = false;

            if (_lostFocusCancels)
            {
                if (!_applied)
                {
                    Text.Format("{0}", _original);
                    OnCancel();
                }
            }
            else
            {
                OnApply();
            }

            UiTask.BeginInvoke(() => CallDelegate("LostFocus"));
        }
Exemplo n.º 28
0
        private LoadingServerListContext NewThread(Collection <IServerItem> dest, CancellationToken token, int blockCount,
                                                   int i)
        {
            var thread = new Thread(LoadingServerList)
            {
                Name         = "UDP" + (i + 1),
                IsBackground = true,
                Priority     = ThreadPriority.Lowest
            };
            var threadContext = new LoadingServerListContext
            {
                Dest  = dest,
                Ips   = _serverIPListe.Skip(blockCount * i).Take(blockCount).ToArray(),
                Token = token
            };

            UiTask.Run(ReloadThreads.Add, threadContext).Wait(0);
            thread.Start(threadContext);
            return(threadContext);
        }
Exemplo n.º 29
0
        public void Open()
        {
            UiTask.BeginInvoke(() =>
            {
                string path = Platform.OpenFileDialog("Open file", "Map file (*.smf)|*.smf|All files|*.*");

                if (path != null)
                {
                    if (!Document.Current.IsModified)
                    {
                        Open(path);
                        HideElement("FileMenu");
                        return;
                    }

                    MessageBox.YesNoCancel(SaveChangesQuestion,
                                           () =>
                    {
                        UiTask.BeginInvoke(() =>
                        {
                            if (SaveInternal())
                            {
                                Open(path);
                            }
                        });
                    },
                                           () =>
                    {
                        Open(path);
                    },
                                           () =>
                    {
                        HideElement("FileMenu");
                    });
                }
                else
                {
                    HideElement("FileMenu");
                }
            });
        }
Exemplo n.º 30
0
        public ServerListViewModel()
        {
            if (!System.IO.Directory.Exists(ArmaBrowserAddonFolder))
            {
                System.IO.Directory.CreateDirectory(ArmaBrowserAddonFolder);
            }

            UpdateAvailable = new UpdateAvailableViewModel();
            UpdateAvailable.CheckForNewReleases().Wait(0);

            _version = this.GetType().Assembly.GetName().Version.ToString();

            UiTask.Initialize();
            _context = new LogicContext();
            if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
            {
                return;
            }

            _context.ServerItems.CollectionChanged += _serverItems_CollectionChanged;
            _context.PropertyChanged += Context_PropertyChanged;

            TextFilter        = Properties.Settings.Default.TextFilter;
            _selectedEndPoint = Properties.Settings.Default.LastPlayedHost;

            LookForInstallation();

            string[]      recentlyHosts       = Properties.Settings.Default.RecentlyHosts.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Reverse().ToArray();
            IServerItem[] recentlyServerItems = _context.AddServerItems(recentlyHosts);
            foreach (var item in recentlyServerItems)
            {
                item.LastPlayed = DateTime.Now;
            }
            var refreshRecentlyServerItemsTask = _context.RefreshServerInfoAsync(recentlyServerItems);

            refreshRecentlyServerItemsTask.ContinueWith((t, o) => ServerItemsView.Refresh(), null, TaskScheduler.FromCurrentSynchronizationContext());

            Task.Run((Action)EndlessRefreshSelecteItem);
        }