コード例 #1
0
        private void LpViewModel_DeleteProgramEvent(string arg1, ProgramViewModel arg2)
        {
            string message = $"确定删除 【{arg1}】本地目录下的【{arg2.Name}】 程序吗?";
            var    confirm = new ConfirmControl(message);
            var    popup   = new PopupWindow(confirm, 480, 180, "删除本地程序");

            confirm.ConfirmOkEvent += () =>
            {
                if (File.Exists(System.IO.Path.Combine(arg1, arg2.Name)))
                {
                    try
                    {
                        File.Delete(System.IO.Path.Combine(arg1, arg2.Name));
                        var obj = lpViewModel.LocalProgramList.FirstOrDefault(d => d.FillName == arg2.FillName) ?? new ProgramViewModel();
                        lpViewModel.LocalProgramList.Remove(obj);
                        Messenger.Default.Send(new Common.ViewModel.NotifiactionModel()
                        {
                            Title            = "删除本地程序",
                            Content          = $"成功删除本地程序【{arg2.Name}】!",
                            NotifiactionType = Common.ViewModel.EnumPromptType.Success
                        });
                    }
                    catch (Exception)
                    {
                        Messenger.Default.Send(new Common.ViewModel.NotifiactionModel()
                        {
                            Title            = "删除本地程序",
                            Content          = $"删除本地程序【{arg2.Name}】出错,请稍后重试!",
                            NotifiactionType = Common.ViewModel.EnumPromptType.Error
                        });
                    }
                }
                popup.Close();
            };
            confirm.ConfirmCancelEvent += () => popup.Close();
            popup.ShowDialog();
            lpViewModel.RefreshPage();
        }
コード例 #2
0
        private void CpViewModel_DeleteProgramEvent()
        {
            string message = $"确定删除 【{cpViewModel.CNCPath}】目录下的【{cpViewModel.CurrentSelectModel.Name}】 程序吗?";
            var    confirm = new ConfirmControl(message);
            var    popup   = new PopupWindow(confirm, 480, 180, "删除CNC程序");

            confirm.ConfirmOkEvent += () =>
            {
                RealReadWriterEvent?.Invoke(new HubReadWriterModel()
                {
                    ProxyName  = "ProgramTransferInOut",
                    Action     = "DeleteProgram",
                    Id         = "deleteProgram",
                    SuccessTip = $"成功删除 【{cpViewModel.CNCPath}】目录【{cpViewModel.CurrentSelectModel.Name}】 程序!",
                    Data       = new object[] { $"{cpViewModel.CNCPath}{cpViewModel.CurrentSelectModel.Name}" }
                });
                var obj = cpViewModel.LocalProgramList.FirstOrDefault(d => d.Name == cpViewModel.CurrentSelectModel.Name) ?? new ProgramViewModel();
                cpViewModel.LocalProgramList.Remove(obj);
                cpViewModel.RefreshPage();
                popup.Close();
            };
            confirm.ConfirmCancelEvent += () => popup.Close();
            popup.ShowDialog();
        }
コード例 #3
0
        private void Start()
        {
            m_editor      = IOC.Resolve <IRTE>();
            m_parentPopup = GetComponentInParent <PopupWindow>();
            if (m_parentPopup != null)
            {
                m_parentPopup.OK.AddListener(OnOK);
            }

            m_treeView = GetComponentInChildren <VirtualizingTreeView>();
            if (m_treeView == null)
            {
                m_treeView = Instantiate(TreeViewPrefab);
                m_treeView.transform.SetParent(transform, false);
            }

            m_treeView.ItemDataBinding += OnItemDataBinding;
            m_treeView.ItemDoubleClick += OnItemDoubleClick;
            m_treeView.ItemExpanding   += OnItemExpanding;

            m_treeView.CanDrag = false;
            m_treeView.CanEdit = false;

            m_project = IOC.Resolve <IProject>();

            m_editor.IsBusy = true;
            m_project.LoadAssetLibrary(Array.IndexOf(m_project.AssetLibraries, m_selectedAssetLibrary), (error, root) =>
            {
                m_editor.IsBusy = false;
                if (error.HasError)
                {
                    PopupWindow.Show("Unable to load AssetLibrary", error.ErrorText, "OK", arg =>
                    {
                        m_parentPopup.Close(false);
                    });
                }
                else
                {
                    m_treeView.Items         = new[] { root };
                    m_treeView.SelectedItems = root.Flatten(false);
                    ExpandAll(root);


                    IResourcePreviewUtility resourcePreview = IOC.Resolve <IResourcePreviewUtility>();
                    StartCoroutine(ProjectItemView.CoCreatePreviews(root.Flatten(false), m_project, resourcePreview));
                }
            });
        }
コード例 #4
0
        void Shell_ShowReports(object sender, System.EventArgs e)
        {
            IReportPresenter presenter = container.Resolve <IReportPresenter>();

            if (reportW != null)
            {
                try { reportW.Close(); }
                catch { }
            }


            reportW          = new PopupWindow();
            reportW.Closing += new System.ComponentModel.CancelEventHandler(reportW_Closing);
            reportW.ShowViewInShell(presenter.View, "WMS Express Reports");
            reportW.WindowState = System.Windows.WindowState.Maximized;
            reportW.Show();
        }
コード例 #5
0
        private void OnResourcesDoubleClick(object sender, ProjectResourcesEventArgs e)
        {
            if (e.ItemObjectPair != null && e.ItemObjectPair.IsNone)
            {
                IsNoneSelected = true;
            }
            else
            {
                IsNoneSelected = false;
                if (e.ItemObjectPair != null)
                {
                    SelectedObject = e.ItemObjectPair.Object;
                }
                else
                {
                    SelectedObject = null;
                }
            }

            m_parentPopup.Close(true);
        }
コード例 #6
0
        public override void OnMessage(Message message)                       //主菜单消息发送
        {
            string name = message.Name;

            object[] body = message.Params;
            bool     isStopPlayDubbing = true;

            switch (name)
            {
            case MessageConst.CMD_MAIN_ON_STAR_ACTIVITY_BTN:
                if (GlobalData.MissionModel.IsShowStarActivity())
                {
                    ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_STAR_ACTIVITY, false, true, GlobalData.MissionModel.GetOpenDay());
                }
                else
                {
                    view.HandleFunctionOpen();
                }
                break;

            case MessageConst.CMD_MAIN_CHANGE_DISPLAY:                                    //--主菜单显示状态 Star
                MainMenuDisplayState state = (MainMenuDisplayState)message.Body;

                PopupManager.StopHandleShowWindow();

                switch (state)
                {
                case MainMenuDisplayState.ShowAll:
                    view.ShowAll();
                    //CheckNeedToDownLoadExtend();

                    PopupManager.ShowPhoneTipsWindow(() => SendRedPoint());
                    break;

                case MainMenuDisplayState.ShowUserInfo:
                    view.ShowUserInfo();
                    break;

                case MainMenuDisplayState.ShowUserInfoAndTopBar:
                    view.ShowTopBarAndUserInfo();
                    break;

                case MainMenuDisplayState.ShowTopBar:
                    view.ShowTopBar();
                    break;

                case MainMenuDisplayState.ShowVisitTopBar:
                    view.ShowTopBar(MainMenuDisplayState.ShowVisitTopBar);
                    break;

                case MainMenuDisplayState.HideAll:

                    if (_window != null)
                    {
                        _window.Close();
                    }

                    view.ShowAll(false);

                    break;

                case MainMenuDisplayState.ShowRecollectionTopBar:
                    view.ShowTopBar(MainMenuDisplayState.ShowRecollectionTopBar);
                    break;

                case MainMenuDisplayState.ShowExchangeIntegralBar:
                    view.ExchangeIntegralBarSetData(GlobalData.TrainingRoomModel.GetCurIntegral());
                    view.ShowTopBar(MainMenuDisplayState.ShowExchangeIntegralBar);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }                                                                        //--主菜单显示状态 End
                break;

            case MessageConst.CMD_MAIN_ON_START_BTN:
                var isShowArrow = (bool)body[0];
                Debug.LogError("isShowArrow===>" + isShowArrow);
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_GAME_PLAY, false, true, isShowArrow);       //--模块消息发送 Start
                break;

            case MessageConst.CMD_MAIN_ON_CARD_BTN:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_CARD);
                break;

            case MessageConst.CMD_MAIN_ON_SUPPORTER_BTN:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_SUPPORTER);
                break;

            case MessageConst.CMD_TASK_SHOW_DAILYTASK:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_MISSION);
                break;

            case MessageConst.CMD_GOTOACHIEVEMENT:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_ACHIEVEMENT);
                break;

            case MessageConst.CMD_APPOINTMENT_JUMPCHOOSEROLE:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_LOVE);
                //PopupManager.ShowWindow<LoveJumpWindow>("GameMain/Prefabs/LoveJumpWindow/LoveJumpWindow");
                break;

            case MessageConst.CMD_MAIN_ON_CHANGE_ROLE_BTN:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_FAVORABILITYMAIN);
                break;

            case MessageConst.CMD_MAIN_ON_DRAWCARD_BTN:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_DRAWCARD);
                break;

            case MessageConst.CMD_MAIN_ON_PHONE_BTN:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_PHONE);
                break;

            case MessageConst.CMD_MAIN_ON_ACTIVITY_BTN:
                //SendActivityMsg();
                //进入活动模块
                var id = (string)message.Body;
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_ACTIVITY, false, true, id);
                break;

            case MessageConst.CMD_MAIN_ON_MAIL_BTN:

                PopupManager.StopHandleShowWindow();
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_MAIL);
                break;

            case MessageConst.CMD_MAIN_ON_ALBUM_BTN:
                FlowText.ShowMessage(I18NManager.Get("Common_Underdevelopment"));
                break;

            case MessageConst.CMD_MAIN_ON_STAGINGPOST_BTN:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_SHOP, false, true, 0);
                break;

            case MessageConst.CMD_MAIN_SHOW_BUY_POWER:                               //买体力
                var _buyPowerUpperlimit = GlobalData.PlayerModel.BuyPowerUpperlimit; //10
                if (GlobalData.PlayerModel.PlayerVo.PowerNum >= _buyPowerUpperlimit)
                {
                    FlowText.ShowMessage(I18NManager.Get("Common_TodaysBuyUpperlimit"));    // ("今日兑换次数已达上限");
                    return;
                }
                else
                {
                    ShowBuyPowerWindow();
                }
                break;

            case MessageConst.CMD_MAIN_SHOW_BUY_GOLD:                              //买金币
                var _buyGlodUpperlimit = GlobalData.PlayerModel.BuyGoldUpperlimit; //10
                if (GlobalData.PlayerModel.PlayerVo.GoldNum >= _buyGlodUpperlimit)
                {
                    FlowText.ShowMessage(I18NManager.Get("Common_TodaysBuyUpperlimit"));
                    return;
                }
                else
                {
                    ShowBuyGlodWindow();
                }
                break;

            case MessageConst.CMD_SUPPORTERACTIVITY_BUYENCOURAGEPOWER:                                 //买应援行动力

                var _buyEncouragePowerUpperlimit = GlobalData.PlayerModel.BuyEncouragePowerUpperlimit; //5
                if (GlobalData.PlayerModel.PlayerVo.EncourageNum >= _buyEncouragePowerUpperlimit)
                {
                    FlowText.ShowMessage(I18NManager.Get("Common_TodaysBuyUpperlimit"));
                    return;
                }
                else
                {
                    BuyEncouragePower();
                }
                break;

            case MessageConst.CMD_MAIN_SHOW_BUY_GEM:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_SHOP, false, true, 5);
                //ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_BUYGEN);
//                    ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_PAY,false);

//                    (SdkHelper.PayAgent as PayAgentGooglePlay)?.Test();
                break;

            case MessageConst.CMD_RECOLLECTION_SENDBUYEVENT:
                EventDispatcher.TriggerEvent(EventConst.SendBuyRecolletionPowerEvent);
                break;

            case MessageConst.CMD_MAIN_ON_LIVE2DCLICK:
                isStopPlayDubbing = false;
                SendNpcMainStageInteract();
                break;

            case MessageConst.CMD_MAIN_ON_FIRITSRECHARGE_BTN:
                //通过首冲进入活动模块
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_ACTIVITYFIRSTRECHARGE, false, true);
                break;

            case MessageConst.CMD_MAIN_STORESCORECOMMENT:
                bool   commentType = (bool)body[0];
                string comment     = (string)body[1];
                int    star        = (int)body[2];
                Debug.LogError(comment.Length);
                if (commentType)
                {
                    SetCommentRes(true, comment, star);
                }
                else
                {
                    if (comment.Length < 20)
                    {
                        FlowText.ShowMessage(I18NManager.Get("GameMain_MinTextCount"));
                        return;
                    }
                    else if (comment.Length > 600)
                    {
                        FlowText.ShowMessage(I18NManager.Get("GameMain_MaxTextCount"));
                        return;
                    }
                    SetCommentRes(false, comment, star);
                }


                break;

            case MessageConst.CMD_MAIN_FIRESHDOWNLOADAWARD:
//                    Debug.LogError("has receiveDownload"+GlobalData.PlayerModel.PlayerVo.ExtInfo.DownloadReceive);
                //GuideManager.SetStatisticsRemoteGuideStep(GuideConst.MainLineStep_Extend_DowndLoad);

                if (GlobalData.PlayerModel.PlayerVo.ExtInfo.DownloadReceive == 0)
                {
                    NetWorkManager.Instance.Send <ReceiveDownloadAwardsRes>(CMD.DOWNLOAD_RECEIVEAWARD, null, OnDownloadReceiveAward);
                }
//                    else
//                    {
//                        Debug.LogError("另外奖励又重新删包,在下载");
//                        SendMessage(new Message(MessageConst.CMD_DOWNLOAD_OK));
//                    }



                break;

            case MessageConst.CMD_MAIN_ON_PLAYERBIRTHDAY:
                if (GlobalData.MissionModel.IsShowPlayerBirthday())
                {
                    ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_PLAYERBIRTHDAY, false, true, GlobalData.MissionModel.GetPlayerBirthdayOpenDay());
                }
                else
                {
                    view.HandleFunctionOpen();
                }
                break;

            case MessageConst.CMD_MAIN_ON_ACTIVITYTEMPLATE_BTN:
                if (GlobalData.ActivityModel.IsShowActivityTemplateBtn(ActivityTypePB.ActivityDrawTemplate))
                {
                    ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_ACTIVITYTEMPLATE, false, true);
                }
                else
                {
                    view.HandleFunctionOpen();
                }
                break;

            case MessageConst.CMD_MAIN_ON_ACTIVITYCAPSULETEMPLATE_BTN:

                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_ACTIVITYCAPSULETEMPLATE, false, true);
                break;

            case MessageConst.CMD_MAIN_ON_TOTALRECHARGE_BTN:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_ACTIVITY, false, true, GlobalData.ActivityModel.GetActivityVo(ActivityType.ActivityAccumulativeRecharge).JumpId);
                break;

            case MessageConst.CMD_MAIN_ON_ACTIVITYMUSICTEMPLATE_BTN:
                ModuleManager.Instance.EnterModule(ModuleConfig.MODULE_ACTIVITYMUSICTEMPLATE, false, true);
                break;

            default:
                return;
            }

            if (isStopPlayDubbing)
            {
                StopPlayingDubbing();
            }
        }
コード例 #7
0
        public Dictionary <string, Widget> ParseWidgets(IContainer ParentWidget, Dictionary <string, object> Data)
        {
            Dictionary <string, Widget> Widgets = new Dictionary <string, Widget>();

            foreach (string name in Data.Keys)
            {
                if (!(Data[name] is JObject))
                {
                    throw new Exception($"Expected an Object, but got {Data[name].GetType().Name} in key '{name}' inside 'widgets'");
                }
                Dictionary <string, object> config = ((JObject)Data[name]).ToObject <Dictionary <string, object> >();
                if (!config.ContainsKey("type"))
                {
                    throw new Exception($"Widget definition must contain a 'type' key in widget '{name}'");
                }
                if (!(config["type"] is string))
                {
                    throw new Exception($"Widget type must be a string.");
                }
                Widget w    = null;
                string type = (string)config["type"];
                switch (type)
                {
                case "label":
                    w = new Label(ParentWidget);
                    break;

                case "numeric":
                    w = new NumericBox(ParentWidget);
                    break;

                case "textbox":
                    w = new TextBox(ParentWidget);
                    break;

                case "button":
                    w = new Button(ParentWidget);
                    break;

                case "dropdown":
                    w = new DropdownBox(ParentWidget);
                    break;

                default:
                    throw new Exception($"Unknown widget type '{type}' in widget '{name}'");
                }
                if (WidgetLookup.ContainsKey(name))
                {
                    throw new Exception($"Two or more widgets with the same were found: '{name}'");
                }
                WidgetLookup.Add(name, w);
                int             X         = 0;
                int             Y         = 0;
                int             Width     = -1;
                int             Height    = -1;
                string          text      = null;
                int             wvalue    = 0;
                int?            min_value = null;
                int?            max_value = null;
                Font            font      = null;
                List <ListItem> items     = null;
                int             idx       = -1;
                foreach (string key in config.Keys)
                {
                    if (key == "type")
                    {
                        continue;
                    }
                    object value = config[key];
                    switch (key)
                    {
                    case "x":
                        EnsureType(typeof(long), value, "x");
                        X = Convert.ToInt32(value);
                        break;

                    case "y":
                        EnsureType(typeof(long), value, "y");
                        Y = Convert.ToInt32(value);
                        break;

                    case "width":
                        EnsureType(typeof(long), value, "width");
                        Width = Convert.ToInt32(value);
                        if (Width < 1)
                        {
                            throw new Exception($"Widget width ({Width}) must be greater than 0.");
                        }
                        break;

                    case "height":
                        EnsureType(typeof(long), value, "height");
                        Height = Convert.ToInt32(value);
                        if (Height < 1)
                        {
                            throw new Exception($"Widget height ({Height}) must be greater than 0.");
                        }
                        break;

                    case "font":
                        if (type != "label" && type != "textbox" && type != "button" && type != "dropdown")
                        {
                            throw new Exception($"Widget type ({type}) can not contain a 'font' field.");
                        }
                        if (value is string)
                        {
                            if (!Fonts.ContainsKey((string)value))
                            {
                                throw new Exception($"Undefined font name '{(string) value}");
                            }
                            font = Fonts[(string)value];
                        }
                        else if (value is JObject)
                        {
                            font = ParseFont(((JObject)value).ToObject <Dictionary <string, object> >());
                        }
                        else
                        {
                            throw new Exception($"Expected a String or Object, but got {value.GetType().Name} in 'font'");
                        }
                        break;

                    case "value":
                        if (type != "numeric")
                        {
                            throw new Exception($"Widget type ({type}) can not contain a 'value' field.");
                        }
                        EnsureType(typeof(long), value, "value");
                        wvalue = Convert.ToInt32(value);
                        break;

                    case "min_value":
                        if (type != "numeric")
                        {
                            throw new Exception($"Widget type ({type}) can not contain a 'min_value' field.");
                        }
                        EnsureType(typeof(long), value, "min_value");
                        min_value = Convert.ToInt32(value);
                        break;

                    case "max_value":
                        if (type != "numeric")
                        {
                            throw new Exception($"Widget type ({type}) can not contain a 'max_value' field.");
                        }
                        EnsureType(typeof(long), value, "max_value");
                        max_value = Convert.ToInt32(value);
                        break;

                    case "text":
                        if (type != "label" && type != "textbox" && type != "button")
                        {
                            throw new Exception($"Widget type ({type}) can not contain a 'text' field.");
                        }
                        EnsureType(typeof(string), value, "text");
                        text = (string)value;
                        break;

                    case "items":
                        if (type != "dropdown")
                        {
                            throw new Exception($"Widget type ({type}) can not contain an 'items' field.");
                        }
                        if (!(value is JArray))
                        {
                            throw new Exception($"Expected an Array, but got {value.GetType().Name} in key 'items'");
                        }
                        List <object> ary = ((JArray)value).ToObject <List <object> >();
                        items = new List <ListItem>();
                        foreach (object o in ary)
                        {
                            EnsureType(typeof(string), o, "items");
                            items.Add(new ListItem((string)o));
                        }
                        break;

                    case "index":
                        if (type != "dropdown")
                        {
                            throw new Exception($"Widget type ({type}) can not contain an 'index' field.");
                        }
                        EnsureType(typeof(long), value, "index");
                        idx = Convert.ToInt32(value);
                        if (idx < 0)
                        {
                            throw new Exception($"Index field must be greater than or equal to 0.");
                        }
                        break;

                    case "clicked":
                        if (type != "button")
                        {
                            throw new Exception($"Widget type ({type}) can not contain a 'clicked' field.");
                        }
                        if (!(value is JObject))
                        {
                            throw new Exception($"Expected an Object, but got {value.GetType().Name} in key 'clicked'");
                        }
                        Dictionary <string, object> clickdata = ((JObject)value).ToObject <Dictionary <string, object> >();
                        if (!clickdata.ContainsKey("type"))
                        {
                            throw new Exception("'clicked' definition must contain a 'type' key.");
                        }
                        if (!(clickdata["type"] is string))
                        {
                            throw new Exception($"Expected a String, but got {clickdata["type"].GetType().Name} in key 'type'");
                        }
                        string clicktype = (string)clickdata["type"];
                        bool   save      = false;
                        bool   close     = false;
                        foreach (string clickkey in clickdata.Keys)
                        {
                            if (clickkey == "type")
                            {
                                continue;
                            }
                            object clickvalue = clickdata[clickkey];
                            switch (clickkey)
                            {
                            case "action":
                                EnsureType(typeof(string), clickvalue, "action");
                                string action = (string)clickvalue;
                                switch (action)
                                {
                                case "save":
                                    save = true;
                                    break;

                                case "close":
                                    close = true;
                                    break;

                                case "save_and_close":
                                    save  = true;
                                    close = true;
                                    break;

                                default:
                                    throw new Exception($"Unknown value '{action}' inside 'action' definition.");
                                }
                                break;

                            default:
                                throw new Exception($"Unknown key '{key}' inside 'clicked' definition");
                            }
                        }
                        ((Button)w).OnClicked += delegate(BaseEventArgs e)
                        {
                            if (save)
                            {
                                Save();
                            }
                            if (close)
                            {
                                Window.Close();
                            }
                        };
                        break;

                    default:
                        throw new Exception($"Unknown key '{key}' inside widget definition");
                    }
                    w.SetPosition(X, Y);
                    if (Width != -1)
                    {
                        w.SetWidth(Width);
                    }
                    if (Height != -1)
                    {
                        w.SetHeight(Height);
                    }
                    if (type == "label")
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            ((Label)w).SetText(text);
                        }
                        if (font != null)
                        {
                            ((Label)w).SetFont(font);
                        }
                    }
                    if (type == "textbox")
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            ((TextBox)w).SetInitialText(text);
                        }
                        if (font != null)
                        {
                            ((TextBox)w).TextArea.SetFont(font);
                        }
                    }
                    if (type == "numeric")
                    {
                        ((NumericBox)w).SetValue(wvalue);
                        if (min_value != null)
                        {
                            ((NumericBox)w).MinValue = (int)min_value;
                        }
                        if (max_value != null)
                        {
                            ((NumericBox)w).MaxValue = (int)max_value;
                        }
                    }
                    if (type == "button")
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            ((Button)w).SetText(text);
                        }
                        if (font != null)
                        {
                            ((Button)w).SetFont(font);
                        }
                    }
                    if (type == "dropdown")
                    {
                        if (items == null && idx != -1 || items != null && idx >= items.Count)
                        {
                            throw new Exception($"Index cannot be greater than or equal to the total item size.");
                        }
                        if (items != null)
                        {
                            ((DropdownBox)w).SetItems(items);
                        }
                        if (idx != -1)
                        {
                            ((DropdownBox)w).SetSelectedIndex(idx);
                        }
                        if (font != null)
                        {
                            ((DropdownBox)w).SetFont(font);
                        }
                    }
                }
                Widgets.Add(name, w);
            }
            return(Widgets);
        }
コード例 #8
0
 private void OnItemDoubleClick(object sender, ItemArgs e)
 {
     m_parentPopup.Close(true);
 }
コード例 #9
0
        private void ShowCredentialDialog()
        {
            var isLogin = FindElement.Settings.CredentialLogin;

            if (isLogin)
            {
                PopupWindow popupLogin = new PopupWindow()
                {
                    MinWidth                   = 400,
                    FontFamily                 = TryFindResource("TeacherYar.Fonts.IRANSans") as FontFamily,
                    FontSize                   = 14,
                    Title                      = "ورود به نرم افزار",
                    WindowStartupLocation      = WindowStartupLocation.CenterScreen,
                    HorizontalContentAlignment = HorizontalAlignment.Center,
                    ShowInTaskbar              = true,
                    AllowsTransparency         = true,
                    WindowStyle                = WindowStyle.None
                };
                popupLogin.Closing += (s, e) =>
                {
                    e.Cancel = isLogin;

                    if (e.Cancel = isLogin)
                    {
                        Environment.Exit(0);
                    }
                };
                StackPanel mainStack = new StackPanel()
                {
                    FlowDirection = FlowDirection.RightToLeft
                };
                TextBox txtUsername = new TextBox()
                {
                    TabIndex = 0, Style = TryFindResource("TextBoxExtend") as Style, Margin = new System.Windows.Thickness(10)
                };
                System.Windows.Controls.PasswordBox txtPassword = new System.Windows.Controls.PasswordBox()
                {
                    TabIndex = 1, Style = TryFindResource("PasswordBoxExtend") as Style, Margin = new System.Windows.Thickness(10)
                };

                InfoElement.SetContentHeight(txtUsername, 35);
                InfoElement.SetContentHeight(txtPassword, 35);

                InfoElement.SetTitle(txtUsername, "نام کاربری و رمز عبور خود را وارد کنید");
                InfoElement.SetTitleAlignment(txtUsername, TitleAlignment.Top);

                InfoElement.SetPlaceholder(txtUsername, "نام کاربری");
                InfoElement.SetPlaceholder(txtPassword, "رمز عبور ");

                Style  buttonStyle = TryFindResource("ButtonPrimary") as Style;
                Button btnCancel   = new Button {
                    TabIndex = 3, IsCancel = true, Margin = new System.Windows.Thickness(10, 0, 10, 0), Style = buttonStyle, Content = "انصراف", Width = 100, HorizontalContentAlignment = HorizontalAlignment.Center
                };
                Button btnLogin = new Button {
                    TabIndex = 2, IsDefault = true, Margin = new System.Windows.Thickness(10, 0, 10, 0), Style = buttonStyle, Content = "ورود", Width = 100, HorizontalContentAlignment = HorizontalAlignment.Center
                };

                btnCancel.Click += (s, e) => { Environment.Exit(0); };
                btnLogin.Click  += (s, e) =>
                {
                    try
                    {
                        using (var db = new DataClass.myDbContext())
                        {
                            var usr = db.Users.Where(x => x.Username == txtUsername.Text && x.Password == txtPassword.Password);
                            if (usr.Any())
                            {
                                isLogin = false;
                                popupLogin.Close();
                            }
                            else
                            {
                                txtPassword.Focus();
                                txtPassword.Password = string.Empty;
                                InfoElement.SetPlaceholder(txtPassword, "مشخصات اشتباه است دوباره امتحان کنید");
                            }
                        }
                    }
                    catch (InvalidOperationException)
                    {
                    }
                };

                StackPanel btnStack = new StackPanel {
                    Orientation = Orientation.Horizontal, Margin = new Thickness(10), HorizontalAlignment = HorizontalAlignment.Center
                };

                btnStack.Children.Add(btnLogin);
                btnStack.Children.Add(btnCancel);

                mainStack.Children.Add(txtUsername);
                mainStack.Children.Add(txtPassword);
                mainStack.Children.Add(btnStack);

                popupLogin.PopupElement = mainStack;
                popupLogin.ShowDialog();
            }
        }