public override object Eval(IExecutionContext context) { if(context is WindowContext) wincontext = (WindowContext)context; else wincontext = WindowContext.CreateAsChild(context); return base.Eval(wincontext); }
private void SetColumnAttributes(TreeViewColumn column, WindowContext context) { Type t = column.GetType(); t.FindMembers( MemberTypes.Property | MemberTypes.Event, BindingFlags.Public | BindingFlags.Instance, SetGtkPropertyValue, new object[] { column, context }); }
protected override Gtk.Widget CreateWidget(WindowContext context) { Gtk.Toolbar toolbar = new Gtk.Toolbar(); foreach(IWidgetBuilder builder in Childs) { toolbar.Add(builder.Build(context)); } return toolbar; }
protected override Gtk.Widget CreateWidget(WindowContext context) { Gtk.Bin bin = CreateBinWidget(context); if(Child != null) { bin.Child = Child.Build(context); } return bin; }
protected override Gtk.Widget CreateWidget(WindowContext context) { if(this.Child != null) { Gtk.Widget child = this.Child.Build(context); return new Gtk.ToolButton(child, GetAttribute<string>("stock", "")); } return new Gtk.ToolButton(GetAttribute<string>("stock", "")); }
protected override Gtk.Widget CreateWidget(WindowContext context) { if(Childs.Count != 2) throw new Exception("Paned widget musí mít právě dva prvky"); Gtk.Paned paned = CreatePanedWidget(context); paned.Add1(Childs[0].Build(context)); paned.Add2(Childs[1].Build(context)); return paned; }
protected override Gtk.Widget CreateWidget(WindowContext context) { Gtk.Button btn; if(Child != null) { btn = new Gtk.Button(Child.Build(context)); btn.ImagePosition = Gtk.PositionType.Left; } else btn = new Gtk.Button(); return btn; }
protected override Gtk.Widget CreateWidget(WindowContext context) { if(Child == null) throw new Exception("Align musí obsahovat widget"); Gtk.Alignment a = new Gtk.Alignment( GetAtr("x", 0.5f), GetAtr("y", 0.5f), GetAtr("xs", 1.0f), GetAtr("ys", 1.0f)); a.Child = Child.Build(context); return a; }
protected override Widget CreateWidget(WindowContext context) { if(Child == null) throw new Exception("Scrolled musí obsahovat widget"); ScrolledWindow sw = new ScrolledWindow(); Widget child = Child.Build(context); if(IsNativelyScrolled(child.GetType())) sw.Add(child); else sw.AddWithViewport(child); return sw; }
protected override Gtk.Widget CreateWidget(WindowContext context) { if(this.HasAttribute("icon")) { return Gtk.Image.NewFromIconName( this.GetAttribute<string>("icon"), (IconSize)this.GetAttribute<int>("iconsize")); } Gtk.Image image = new Gtk.Image(); if(SetStock(image, "dialog_stock", IconSize.Dialog)) { } else if(SetStock(image, "small_stock", IconSize.Menu)) { } else if(SetStock(image, "button_stock", IconSize.Button)) { } else if(SetStock(image, "smalltool_stock", IconSize.SmallToolbar)) { } else if(SetStock(image, "bigtool_stock", IconSize.LargeToolbar)) { } return image; }
public void Handle(UpdateNewMessage update) { if (update.DisableNotification) { return; } // Adding some delay to be 110% the message hasn't been read already ThreadPoolTimer.CreateTimer(timer => { var chat = _protoService.GetChat(update.Message.ChatId); if (chat == null || chat.LastReadInboxMessageId >= update.Message.Id) { return; } var caption = _protoService.GetTitle(chat); var content = UpdateFromLabel(chat, update.Message) + GetBriefLabel(update.Message); var sound = ""; var launch = "GetLaunch(commonMessage)"; var tag = update.Message.Id.ToString(); var group = GetGroup(update.Message, chat); var picture = string.Empty; var date = BindConvert.Current.DateTime(update.Message.Date).ToString("o"); var loc_key = "CHANNEL"; //var loc_key = commonMessage.Parent is TLChannel channel && channel.IsBroadcast ? "CHANNEL" : string.Empty; Execute.BeginOnUIThread(() => { var service = WindowWrapper.Current().NavigationServices.GetByFrameId("Main"); if (service == null) { return; } if (WindowContext.GetForCurrentView().ActivationState != Windows.UI.Core.CoreWindowActivationState.Deactivated && service.CurrentPageType == typeof(DialogPage) && (long)service.CurrentPageParam == chat.Id) { return; } NotificationTask.UpdateToast(caption, content, sound, launch, tag, group, picture, date, loc_key); NotificationTask.UpdatePrimaryTile(caption, content, picture); }); }, TimeSpan.FromSeconds(2)); }
protected override Gtk.Widget CreateWidget(WindowContext context) { Gtk.Box box = CreateBoxWidget(); foreach(IWidgetBuilder builder in Childs) { if(builder.GetAttribute<bool>("packend", false)) box.PackEnd(builder.Build(context), builder.GetAttribute<bool>("expand", true), builder.GetAttribute<bool>("fill", true), builder.GetAttribute<uint>("padding", 0)); else box.PackStart(builder.Build(context), builder.GetAttribute<bool>("expand", true), builder.GetAttribute<bool>("fill", true), builder.GetAttribute<uint>("padding", 0)); } return box; }
public void CloseWindow(bool isforce, WindowBase windowBase, WindowContext windowContext = null) { for (int i = 0; i < m_windows.Count; i++) { if (this.m_windows[i] == windowBase) { if (this.m_windows[i].m_isUsePool) { this.m_windows[i].Hide(isforce, windowContext); } else { this.m_windows[i].Close(isforce, windowContext); } break; } } }
protected override void OnAppear(int sequence, int openOrder, WindowContext context) { base.OnAppear(sequence, openOrder, context); _loadingContent = context as LoadingContent; Clear(); if (_loadingContent != null) { if (_loadingContent.AppearCallBack != null) { _loadingContent.AppearCallBack.Invoke(); SingletonMono <SceneManager> .GetInstance().ProgressLoad += RefreshInfo; } } else { Debug.LogError("Loading Error ............"); } }
protected virtual void ViewExecute() { NavigationService.GoBack(); var message = _selectedItem as GalleryMessageItem; if (message == null) { return; } var service = WindowContext.GetForCurrentView().NavigationServices.GetByFrameId("Main" + ProtoService.SessionId); if (service != null) { service.NavigateToChat(message.ChatId, message: message.Id); } }
public void CloseWindow(bool isforce, int sque, WindowContext windowContext = null) { for (int i = 0; i < m_windows.Count; i++) { if (this.m_windows[i].GetSequence() == sque) { if (this.m_windows[i].m_isUsePool) { this.m_windows[i].Hide(isforce, windowContext); } else { this.m_windows[i].Close(isforce, windowContext); } break; } } }
public void Appear(int sequence, int openOrder, WindowContext context) { if (!this.m_isInitialized) { return; } if (IsActivied()) { return; } this.m_sequence = sequence; this.m_isPlayClose = false; this.m_isPlayHide = false; this.m_isPlayOpen = false; this.m_isHided = false; this.m_isClosed = false; this.m_isActivied = true; m_appearAnimClipTime = 0; windowState = enWindowState.Appear; this.SetDisplayOrder(openOrder); PlayAppearMusic(); if (m_openAnimClip != null) { var animation = GetComponent <Animation>(); if (animation != null) { animation.Play(m_openAnimClip.name); m_appearAnimClipTime = m_openAnimClip.length; this.m_isPlayOpen = true; } else { Debuger.LogError("设置了OpenAniClip,但是未找到 Animation组件!"); } } if (this.m_canvas != null) { this.m_canvas.enabled = true; } this.TryEnableInput(true); AppearComponent(); OnAppear(sequence, openOrder, context); Debug.Log("<color=#FFFF00>" + "Appear " + WindowInfo.Name + " ................." + "</color>"); }
public void Load(string xml) { if (string.IsNullOrEmpty(xml)) { return; } XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); var widgetNode = doc.SelectSingleNode("/Root/WidgetContexts"); var widgetIter = widgetNode.ChildNodes.GetEnumerator(); while (widgetIter.MoveNext()) { var child = widgetIter.Current as XmlElement; if (child.Name == "WidgetContext") { WidgetContext widget = new WidgetContext(); widget.ParseXml(child); contexts.Add(widget.name, widget); } } var windowNode = doc.SelectSingleNode("/Root/WindowContexts"); var windowIter = windowNode.ChildNodes.GetEnumerator(); while (windowIter.MoveNext()) { var child = windowIter.Current as XmlElement; if (child.Name == "WindowContext") { WindowContext context = new WindowContext(); context.ParseXml(child, GetWidgetContext); contexts.Add(context.name, context); } } }
private WindowState GetWindowState(WindowContext context) { WindowState windowActive = new WindowState(); windowActive.context = context; if (context.widgets != null && context.widgets.Count > 0) { windowActive.widgetsActive = new Dictionary <ulong, bool>(); using (var iter = context.widgets.GetEnumerator()) { while (iter.MoveNext()) { var widget = iter.Current.Value; windowActive.widgetsActive.Add(widget.id, widget.active); } } } return(windowActive); }
protected override void OnAppear(int sequence, int openOrder, WindowContext context) { if (isFirst) { isFirst = false; if (GameData.PlayerInfoModel == null) { FirstGameObject.SetActive(true); EventTriggerListener.Get(CreatePlayerInfoButton.gameObject).SetEventHandle(EnumTouchEventType.OnClick, (a, b, c) => { //点击之后发送注册角色消息 PlayerInfoModel playerInfo = new PlayerInfoModel(); playerInfo.ID = 0; playerInfo.HeadImg = "1.png"; playerInfo.RoleName = CreatePlayerName.text; playerInfo.CoinNum = 200; playerInfo.EXP = 1; playerInfo.LV = 1; playerInfo.AccountID = GameData.AccountData.ID; playerInfo.FriendID = ""; playerInfo.HeroID = ""; playerInfo.Power = 0; playerInfo.WinNum = 0; playerInfo.LostNum = 0; playerInfo.RunNum = 0; //发送数据模型 // Singleton<PhotonManager>.Instance.SendReguest((byte)OperationCode.PlayerInfo, (byte)PlayerInfoOpCode.Create, CommonTool.Serialize<PlayerInfoModel>(playerInfo)); SetCreateButton(false); }); } else { FirstGameObject.SetActive(false); ShowInfo(); } } else { ShowInfo(); } }
/// <summary> /// Trapeze constructor /// </summary> /// <param name="context">Shape context</param> /// <param name="width">Shape width</param> /// <param name="height">Shape height</param> /// <param name="topProportion">Proportion top side to botom side</param> /// <param name="x">Shape center X position</param> /// <param name="y">Shape center Y position</param> public Trapeze(WindowContext context, int width, int height, double topProportion, int x, int y) { this.context = context; this.height = height; this.width = width; positionX = x; positionY = y; double halfWidth = width / 2.0; double halfHeight = height / 2.0; double topSide = width * topProportion; points = new Point[] { new Point(halfWidth, halfHeight), new Point(halfWidth, -halfHeight), new Point(-halfWidth, -halfHeight), new Point(halfWidth - topSide, halfHeight) }; }
public void Hide(bool force, WindowContext context) { if (this.WindowInfo.AlwaysKeepVisible && force == false) { return; } if (IsHided()) { return; } this.m_isHided = true; this.m_isClosed = false; this.m_isActivied = false; windowState = enWindowState.Hide; PlayHideMusic(); m_hideAnimClipTime = 0; this.m_isPlayClose = false; this.m_isPlayHide = false; this.m_isPlayOpen = false; OnHide(context); this.TryEnableInput(false); if (m_hideAnimClip != null) { var animation = GetComponent <Animation>(); if (animation != null) { animation.Play(m_hideAnimClip.name); m_hideAnimClipTime = m_hideAnimClip.length; this.m_isPlayHide = true; } else { Debuger.LogError("设置了CloseAniClip,但是未找到 Animation组件!"); } } else { HideWorker(); } Debug.Log("<color=#FFFF00>" + "Hide " + WindowInfo.Name + " ................." + "</color>"); }
private void Update(Chat chat, Action action) { Execute.BeginOnUIThread(() => { if (_sessionService.IsActive) { var service = WindowContext.GetForCurrentView().NavigationServices.GetByFrameId("Main" + _protoService.SessionId); if (service == null) { return; } if (TLWindowContext.GetForCurrentView().ActivationState != Windows.UI.Core.CoreWindowActivationState.Deactivated && service.CurrentPageType == typeof(ChatPage) && (long)service.CurrentPageParam == chat.Id) { return; } } action(); }); }
/// <summary> /// Create Ellipse shape /// </summary> /// <param name="context">Window context</param> /// <param name="width">Shape width</param> /// <param name="height">Shape height</param> /// <param name="x">X position on window context</param> /// <param name="y">Y position on window context</param> /// <param name="aproximateStep">Frequency finding ellipse points</param> public Ellipse(WindowContext context, int width, int height, int x, int y, int aproximateStep = 3) { this.context = context; this.height = height; this.width = width; positionX = x; positionY = y; focusDistance = Math.Max(width, height); int halfWidth = (int)Math.Floor(width / 2.0); int halfHeight = (int)Math.Floor(height / 2.0); // Find focus offset int c = (int)Math.Sqrt(Math.Pow(halfWidth, 2) - Math.Pow(halfHeight, 2)); // Find focus points focus1 = new Point(c, 0); focus2 = new Point(-c, 0); Redraw(aproximateStep); }
private void Push(WindowContext context) { if (context == null) { return; } if (context.fixedOrder == 0) { WindowNav nav = new WindowNav(); nav.windowState = GetWindowState(context); if (context.hideOther) { using (var it = mWindowContextDic.GetEnumerator()) { while (it.MoveNext()) { var w = it.Current.Value as WindowContext; if (w != null && w != context && w.active) { if (nav.hideWindowStates == null) { nav.hideWindowStates = new List <WindowState>(); } WindowState windowState = GetWindowState(w); nav.hideWindowStates.Add(windowState); SetActive(w, false); } } } if (nav.hideWindowStates != null) { nav.hideWindowStates.Sort(SortWindow); } } mWindowStack.Insert(0, nav); } }
public TreeViewColumn CreateColumn(WindowContext context) { string title = Params.Get<string>("title", ""); TreeViewColumn column; switch(this.ColumnType) { case "text": column = new TreeViewColumn(title, new CellRendererText(), "text", this.StoreIndex); break; case "markup": column = new TreeViewColumn(title, new CellRendererText(), "markup", this.StoreIndex); break; case "pixbuf": column = new TreeViewColumn(title, new CellRendererPixbuf(), "stock-id", this.StoreIndex); break; default: throw new NotSupportedException("Sloupec typu '"+this.ColumnType+"' není podporován"); } SetColumnAttributes(column, context); return column; }
private void Destroy(NavigationService master) { if (master.Frame.Content is IRootContentPage content) { content.Root = null; content.Dispose(); } master.Frame.Navigating -= OnNavigating; master.Frame.Navigated -= OnNavigated; master.Frame.Navigate(typeof(BlankPage)); var detail = WindowContext.GetForCurrentView().NavigationServices.GetByFrameId($"Main{master.FrameFacade.FrameId}"); if (detail != null) { detail.Navigate(typeof(BlankPage)); } WindowContext.GetForCurrentView().NavigationServices.Remove(master); WindowContext.GetForCurrentView().NavigationServices.Remove(detail); }
protected override Widget CreateWidget(WindowContext context) { switch(this.Kind) { case MenuExpressionKind.MenuBar: MenuBar bar = new MenuBar(); AppendItems(bar, context); return bar; case MenuExpressionKind.Menu: MenuItem item = CreateMenuItem(context); Menu menu = new Menu(); item.Submenu = menu; AppendItems(menu, context); return item; case MenuExpressionKind.MenuItem: return CreateMenuItem(context); case MenuExpressionKind.ItemSeparator: return new SeparatorMenuItem(); default: throw new NotImplementedException(); } }
private void OnLoaded(object sender, RoutedEventArgs e) { UpdateVisualState(); if (CurrentState == MasterDetailState.Narrow && DetailFrame.CurrentSourcePageType == BlankPageType) { MasterPresenter.Visibility = Visibility.Visible; } else if (CurrentState == MasterDetailState.Filled) { MasterPresenter.Visibility = Visibility.Visible; } else { MasterPresenter.Visibility = Visibility.Collapsed; } if (CurrentState != MasterDetailState.Narrow && ViewStateChanged != null) { ViewStateChanged(this, EventArgs.Empty); } WindowContext.GetForCurrentView().AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated; }
public WindowContextManager2010() { this.windowContext = new WindowContext(); }
private void CreateColumns(WindowContext context, TreeView view) { foreach(TreeViewColumnExpression col in this.Columns) view.AppendColumn(col.CreateColumn(context)); }
protected override Widget CreateWidget(WindowContext context) { TreeView view = new TreeView(); CreateColumns(context, view); return view; }
protected override Gtk.Widget CreateWidget(WindowContext context) { Gtk.Label l = new Gtk.Label(); l.Markup = this.Markup; return l; }
private MenuItem CreateMenuItem(WindowContext context) { if(HasAttribute("stock")) { ImageMenuItem imi = new ImageMenuItem(this.GetAttribute<string>("stock"), context.AccelGroup); //IconSet icons = IconFactory.LookupDefault(); //imi.Image = new Image(icons.RenderIcon(imi.Style, TextDirection.Ltr, StateType.Normal, IconSize.Menu, imi, null)); return imi; } return new MenuItem(GetAttribute<string>("title","")); }
protected void AppendItems(MenuShell shell, WindowContext context) { if(this.MenuItems != null) foreach(MenuExpression expr in this.MenuItems) shell.Append(expr.Build(context)); }
protected override Gtk.Paned CreatePanedWidget(WindowContext context) { return new Gtk.VPaned(); }
public virtual Gtk.Bin CreateBinWidget(WindowContext context) { return (Gtk.Bin)Activator.CreateInstance(this.BinType); }
protected abstract Gtk.Paned CreatePanedWidget(WindowContext context);
/// <summary> /// Initializes this instance. /// </summary> /// <param name="settings">The settings.</param> protected virtual void Initialize(WindowContext settings) { base.Initialize(settings); InitializeSelf(settings); }
public WindowsController(WindowContext context) { _context = context; }
public override void Clear() { base.Clear(); mParent = null; }
public WindowContext(WindowContext settings) { Initialize(settings); }
private async void SendExecute() { var chats = SelectedItems.ToList(); if (chats.Count == 0) { return; } if (!string.IsNullOrEmpty(_comment)) { var formatted = GetFormattedText(_comment); foreach (var chat in chats) { var response = await ProtoService.SendAsync(new SendMessage(chat.Id, 0, false, false, null, new InputMessageText(formatted, false, false))); } } if (_messages != null) { if (_sendAsCopy) { foreach (var message in _messages) { if (!_messageFactory.CanBeCopied(message)) { var confirm = await TLMessageDialog.ShowAsync("Polls, voice and video notes can't be forwarded as copy. Do you want to proceed anyway?", Strings.Resources.AppName, Strings.Resources.Forward, Strings.Resources.Cancel); if (confirm != ContentDialogResult.Primary) { return; } } } } foreach (var chat in chats) { if (IsWithMyScore) { var response = await ProtoService.SendAsync(new SendMessage(chat.Id, 0, false, false, null, new InputMessageForwarded(_messages[0].ChatId, _messages[0].Id, true, false, false))); } else { var response = await ProtoService.SendAsync(new ForwardMessages(chat.Id, _messages[0].ChatId, _messages.Select(x => x.Id).ToList(), false, false, true, _sendAsCopy, _removeCaptions)); } } //NavigationService.GoBack(); } else if (_inputMedia != null) { foreach (var chat in chats) { var response = await ProtoService.SendAsync(new SendMessage(chat.Id, 0, false, false, null, _inputMedia)); } //NavigationService.GoBack(); } else if (_shareLink != null) { var formatted = new FormattedText(_shareLink.AbsoluteUri, new TextEntity[0]); foreach (var chat in chats) { var response = await ProtoService.SendAsync(new SendMessage(chat.Id, 0, false, false, null, new InputMessageText(formatted, false, false))); } //NavigationService.GoBack(); } else if (_inviteBot != null) { var chat = chats.FirstOrDefault(); if (chat == null) { return; } var response = await ProtoService.SendAsync(new SetChatMemberStatus(chat.Id, _inviteBot.Id, new ChatMemberStatusMember())); if (response is Ok) { if (_inviteToken != null) { response = await ProtoService.SendAsync(new SendBotStartMessage(_inviteBot.Id, chat.Id, _inviteToken)); var service = WindowContext.GetForCurrentView().NavigationServices.GetByFrameId("Main" + ProtoService.SessionId); if (service != null) { service.NavigateToChat(chat, accessToken: _inviteToken); } } //NavigationService.GoBack(); } } else if (_switchInline != null && _switchInlineBot != null) { var chat = chats.FirstOrDefault(); if (chat == null) { return; } var state = new Dictionary <string, object>(); state["switch_query"] = _switchInline.Query; state["switch_bot"] = _switchInlineBot.Id; //NavigationService.GoBack(); var service = WindowContext.GetForCurrentView().NavigationServices.GetByFrameId("Main" + ProtoService.SessionId); if (service != null) { service.NavigateToChat(chat, state: state); } } else if (_package != null) { var chat = chats.FirstOrDefault(); if (chat == null) { return; } App.DataPackages[chat.Id] = _package; var service = WindowContext.GetForCurrentView().NavigationServices.GetByFrameId("Main" + ProtoService.SessionId); if (service != null) { service.NavigateToChat(chat); } } //App.InMemoryState.ForwardMessages = new List<TLMessage>(messages); //NavigationService.GoBackAt(0); }
private async void SendExecute() { var chats = SelectedItems.ToList(); if (chats.Count == 0) { return; } if (!string.IsNullOrEmpty(_comment)) { var formatted = GetFormattedText(_comment); foreach (var chat in chats) { var response = await ProtoService.SendAsync(new SendMessage(chat.Id, 0, false, false, null, new InputMessageText(formatted, false, false))); } } if (_messages != null) { foreach (var chat in chats) { if (IsWithMyScore) { var response = await ProtoService.SendAsync(new SendMessage(chat.Id, 0, false, false, null, new InputMessageForwarded(_messages[0].ChatId, _messages[0].Id, true))); } else { var response = await ProtoService.SendAsync(new ForwardMessages(chat.Id, _messages[0].ChatId, _messages.Select(x => x.Id).ToList(), false, false, false)); } } //NavigationService.GoBack(); } else if (_inputMedia != null) { foreach (var chat in chats) { var response = await ProtoService.SendAsync(new SendMessage(chat.Id, 0, false, false, null, _inputMedia)); } //NavigationService.GoBack(); } else if (_shareLink != null) { var formatted = new FormattedText(_shareLink.ToString(), new TextEntity[0]); foreach (var chat in chats) { var response = await ProtoService.SendAsync(new SendMessage(chat.Id, 0, false, false, null, new InputMessageText(formatted, false, false))); } //NavigationService.GoBack(); } else if (_inviteBot != null) { var chat = chats.FirstOrDefault(); if (chat == null) { return; } var response = await ProtoService.SendAsync(new SetChatMemberStatus(chat.Id, _inviteBot.Id, new ChatMemberStatusMember())); if (response is Ok) { //NavigationService.GoBack(); } } else if (_switchInline != null && _switchInlineBot != null) { var chat = chats.FirstOrDefault(); if (chat == null) { return; } var state = new Dictionary <string, object>(); state["switch_query"] = _switchInline.Query; state["switch_bot"] = _switchInlineBot.Id; //NavigationService.GoBack(); var service = WindowContext.GetForCurrentView().NavigationServices.GetByFrameId("Main" + ProtoService.SessionId); if (service != null) { service.NavigateToChat(chat, state: state); } } //App.InMemoryState.ForwardMessages = new List<TLMessage>(messages); //NavigationService.GoBackAt(0); }
private void OnLoaded(object sender, RoutedEventArgs e) { WindowContext.GetForCurrentView().AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated; }
public void Display() => WindowContext.SwapBuffers();
private void InitializeSelf(WindowContext settings) { }
protected override void OnClose(WindowContext context) { base.OnClose(context); this.NodeData = null; StopContentText(); }
protected override void OnHide(WindowContext context) { base.OnHide(context); StopContentText(); }
protected override Gtk.Widget CreateWidget(WindowContext context) { uint rows = 0; uint columns = 0; uint wrow = 0; uint wcolumn = 0; uint startrow = 0; uint startcolumn = 0; bool rowmode = GetAttribute<bool>("rowmode", true); rowmode = !GetAttribute<bool>("colmode", !rowmode); List<WidgetTableInfo> wlist = new List<WidgetTableInfo>(Childs.Count); foreach(IWidgetBuilder b in Childs) { WidgetTableInfo w = new WidgetTableInfo(); w.Widget = b.Build(context); startcolumn = b.GetAttribute<uint>("col", startcolumn); startrow = b.GetAttribute<uint>("row", startrow); wcolumn = b.GetAttribute<uint>("col", wcolumn); wrow = b.GetAttribute<uint>("row", wrow); if(b.GetAttribute<bool>("newcol", false)) { wrow = startrow; wcolumn = ++startcolumn; } else if(b.GetAttribute<bool>("newrow", false)) { wcolumn = startcolumn; wrow = ++startrow; } w.Left = wcolumn; w.Right = wcolumn + b.GetAttribute<uint>("colspan", 1u); w.Top = wrow; w.Bottom = wrow + b.GetAttribute<uint>("rowspan", 1u); if(!b.GetAttribute<bool>("xnoexpand", false)) w.XOptions |= Gtk.AttachOptions.Expand; if(!b.GetAttribute<bool>("xnofill", false)) w.XOptions |= Gtk.AttachOptions.Fill; if(b.GetAttribute<bool>("xshrink", false)) w.XOptions |= Gtk.AttachOptions.Shrink; if(!b.GetAttribute<bool>("ynoexpand", false)) w.YOptions |= Gtk.AttachOptions.Expand; if(!b.GetAttribute<bool>("ynofill", false)) w.YOptions |= Gtk.AttachOptions.Fill; if(b.GetAttribute<bool>("yshrink", false)) w.YOptions |= Gtk.AttachOptions.Shrink; w.XPadding = b.GetAttribute<uint>("xpadding", 0u); w.YPadding = b.GetAttribute<uint>("ypadding", 0u); wlist.Add(w); if(rows < w.Bottom) rows = (uint)w.Bottom; if(columns < w.Right) columns = (uint)w.Right; if(rowmode) wcolumn++; else wrow++; } Gtk.Table table = new Gtk.Table(rows, columns, GetAttribute<bool>("homogeneous", false)); List<Gtk.Widget> focuschain = new List<Gtk.Widget>(wlist.Count); foreach(WidgetTableInfo w in wlist) { table.Attach(w.Widget, w.Left, w.Right, w.Top, w.Bottom, w.XOptions, w.YOptions, w.XPadding, w.YPadding); if(w.Widget.CanFocus) focuschain.Add(w.Widget); } table.FocusChain = focuschain.ToArray(); return table; }
public void OpenWindow(string name, bool isusePool, bool useCameraRender = true, WindowContext appear = null) { WindowBase windowBase = GetUnClosedWindow(name); if (windowBase != null && windowBase.WindowInfo.IsSinglen) { windowBase.IsPlayHide = false; windowBase.IsPlayOpen = false;//如果正在关闭动画直接打开 this.RemoveFromExitSquenceList(windowBase.WindowInfo.Priority, windowBase.GetSequence()); this.AddToExitSquenceList(windowBase.WindowInfo.Priority, this.m_windowSequence); int openorder = this.GetWindowOpenOrder(windowBase.WindowInfo.Priority, this.m_windowSequence); windowBase.Appear(this.m_windowSequence, openorder, appear); if (windowBase.WindowInfo.Group > 0) { this.CloseGroupWindow(windowBase.WindowInfo.Group, false); } this.m_windowSequence++; return; } GameObject obj = null; if (isusePool) { for (int i = 0; i < m_pooledWindows.Count; i++) { if (string.Equals(name, this.m_pooledWindows[i].WindowInfo.Name)) { obj = this.m_pooledWindows[i].gameObject; this.m_pooledWindows.RemoveAt(i); break; } } } if (obj == null) { GameObject res = null; Action <Object> callBack = delegate(Object loadobj) { res = loadobj as GameObject; if (res != null) { obj = Object.Instantiate(res); windowBase = obj.GetComponent <WindowBase>(); if (windowBase != null) { windowBase.m_isUsePool = isusePool; } string uiname = GetWindowName(name); obj.name = uiname; if (obj.transform.parent != this.m_root.transform) { obj.transform.SetParent(m_root.transform); } if (windowBase != null) { if (!windowBase.IsInitialized()) { AddCollider(windowBase); windowBase.Init(useCameraRender ? m_UICamera : null); } this.AddToExitSquenceList(windowBase.WindowInfo.Priority, this.m_windowSequence); int openorder = GetWindowOpenOrder(windowBase.WindowInfo.Priority, this.m_windowSequence); windowBase.Appear(this.m_windowSequence, openorder, appear); if (windowBase.WindowInfo.Group > 0) { this.CloseGroupWindow(windowBase.WindowInfo.Group, false); } this.m_windows.Add(windowBase); } this.m_windowSequence++; } }; if (Platform.IsLoadFromBundle) { Singleton <ResourceManager> .GetInstance().AddTask("assetbundles/" + name.ToLower() + ".assetbundle", (loadobj) => { callBack.Invoke(loadobj); }, (int)AssetBundleLoadType.LoadBundleFromFile, (int)CachePriority.NoCache); } else { Singleton <ResourceManager> .GetInstance().LoadResourceAsync <GameObject>(name, (loadobj) => { callBack.Invoke(loadobj); }); } } else { windowBase = obj.GetComponent <WindowBase>(); this.AddToExitSquenceList(windowBase.WindowInfo.Priority, this.m_windowSequence); int openorder = GetWindowOpenOrder(windowBase.WindowInfo.Priority, this.m_windowSequence); windowBase.Appear(this.m_windowSequence, openorder, appear); if (windowBase.WindowInfo.Group > 0) { this.CloseGroupWindow(windowBase.WindowInfo.Group, false); } this.m_windows.Add(windowBase); this.m_windowSequence++; } }
private void OnUnloaded(object sender, RoutedEventArgs e) { WindowContext.GetForCurrentView().AcceleratorKeyActivated -= OnAcceleratorKeyActivated; }
protected override Gtk.Widget CreateWidget(WindowContext context) { Window win; if(HasAttribute("dialog")) { Dialog dialog = new Dialog(); dialog.AddAccelGroup(context.AccelGroup); SetWindowAttribs(dialog); if(Child != null) dialog.VBox.Add(Child.Build(context)); foreach(string s in GetAttribute<Array>("dialog")) { string[] bits = s.Split(':'); string text = bits[0]; int response = 0; if(bits.Length > 4) throw new Exception("Neplatný počet parametrů tlačítka v poli tlačítek dialogu"); if(bits.Length > 1) response = (int)IntLiteral.Parse(bits[1]); Label l = new Label(); l.Markup = text; Button btn; if(bits.Length > 2 && !String.IsNullOrEmpty(bits[2])) { HBox hbox = new HBox(false, 0); hbox.PackStart(ImageExpression.CreateImage(bits[2], IconSize.Button)); hbox.PackStart(l); btn = new Button(hbox); } else btn = new Button(l); btn.ShowAll(); dialog.AddActionWidget(btn, response); if(bits.Length > 3) { switch(bits[3].ToLower()) { case "default": btn.CanDefault = true; dialog.Default = btn; break; case "cancel": // set as cancel action - how? break; case "": case "none": break; default: throw new Exception("Neznámý příznak tlačítka dialogu"); } } } win = dialog; } else { win = new Window(Gtk.WindowType.Toplevel); win.AddAccelGroup(context.AccelGroup); if(Child != null) win.Add(Child.Build(context)); } if(HasAttribute("iconset")) { IconSet icons = IconFactory.LookupDefault(GetAttribute<string>("iconset")); List<Gdk.Pixbuf> list = new List<Gdk.Pixbuf>(); foreach(IconSize size in icons.Sizes) { list.Add(icons.RenderIcon(win.Style, TextDirection.Ltr, StateType.Normal, size, win, "")); } win.IconList = list.ToArray(); } return win; }