示例#1
0
    // Use this for initialization
    public GUIManager()
    {
        // Going to make the layout of the screen in 6s
        sizeDivisor = 6;

        manaInvasion = new ManaInvasion (Screen.width - Screen.width/sizeDivisor, 0, Screen.width/sizeDivisor,Screen.height/sizeDivisor);

        /*
        timeZone = "Future";
        loadCount = 0;

        width = 300;
        height = 120;
        loadTime = 5;
        x = 0;
        y = Screen.height-height;*/
        int height = 120;
        futureButton = new FutureButton("Future", 0, 300,  height, 5, 0, Screen.height - height);

        /*
        width = 100;
        height = 90;
        spacing = 10;*/
        rollingButton = new RollingButton (100,90,10);

        selectorOverlay = new SelectorOverlay();
        castSpell = new CastSpell();
        readyButton = new ReadyButton (Screen.width - Screen.width/sizeDivisor, Screen.height-Screen.height/sizeDivisor, Screen.width/sizeDivisor,Screen.height/sizeDivisor);
        infoWindow = new InfoWindow (Screen.width - Screen.width/sizeDivisor, Screen.height-Screen.height/sizeDivisor*3, Screen.width/sizeDivisor, Screen.height/sizeDivisor*2);
    }
示例#2
0
 public void OpenInfoWindow(MainWindow frmMain)
 {
     InfoWindow frmInfo = new InfoWindow();
     frmInfo.Owner = frmMain;
     frmInfo.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     frmInfo.ShowDialog();
 }
        public InfoWindowBuilder Add()
        {
            var window = new InfoWindow(marker);

            marker.Window = window;

            return new InfoWindowBuilder(window);
        }
 /// <summary>
 /// Method of getting data from SQL.
 /// Called from the method RedisOrSQLStorage.
 /// </summary>
 /// <param name="queryUserStorage">Query our request.</param>
 /// <param name="db">Connecting with Redis.</param>
 /// <param name="redisIsStarted">The flag to check launched Redis.</param>
 /// <param name="logging">Logging class object to create the log.</param>
 /// <param name="frm">Instance a modal window.</param>
 private static void GetDataFromSQL(IEnumerable<User> queryUserStorage, IDatabase db, bool redisIsStarted, Logging logging, InfoWindow frm)
 {
     var user = queryUserStorage.ToList();
     frm.FirstNameParam = user[0].First_Name;
     frm.LastNameParam = user[0].Last_Name;
     frm.AgeParam = user[0].Age.ToString();
     frm.BioParam = user[0].Bio;
     frm.CountryParam = user[0].Country;
     frm.CityParam = user[0].City;
     if (redisIsStarted)
         RedisSetData(db, user, logging);
 }
 private void CheckGameFolder(string mainPath)
 {
     var files = Directory.GetFiles(mainPath);
     if (files.Contains(mainPath + "\\start.exe"))
     {
         Directory.CreateDirectory(mainPath + "\\mods");
     }
     else
     {
         ResourceManager rm = new ResourceManager(typeof(Resources));
         InfoWindow infoWindow = new InfoWindow(rm.GetString("noExe"));
         infoWindow.ShowDialog();
         Environment.Exit(0);
     }
 }
示例#6
0
        public void ShowInfoWindow(string info)
        {
            InfoWindow infoWindow = new InfoWindow(info);

            infoWindow.ShowDialog();
        }
示例#7
0
        /// <summary>
        /// Wake the addon. Creates the server instance and UI.
        /// </summary>
        public void Awake()
        {
            if (!ServicesChecker.OK)
            {
                return;
            }

            Init();

            KRPCServer.Context.SetGameScene(KSPAddonImproved.CurrentGameScene.ToGameScene());
            Logger.WriteLine("Game scene switched to " + KRPCServer.Context.GameScene);

            GUILayoutExtensions.Init(gameObject);

            server.GetUniversalTime = Planetarium.GetUniversalTime;

            // Disconnect client dialog
            clientDisconnectDialog = gameObject.AddComponent <ClientDisconnectDialog> ();

            // Create info window
            infoWindow          = gameObject.AddComponent <InfoWindow> ();
            infoWindow.Server   = server;
            infoWindow.Closable = true;
            infoWindow.Visible  = config.InfoWindowVisible;
            infoWindow.Position = config.InfoWindowPosition;

            // Create main window
            mainWindow          = gameObject.AddComponent <MainWindow> ();
            mainWindow.Config   = config;
            mainWindow.Server   = server;
            mainWindow.Visible  = config.MainWindowVisible;
            mainWindow.Position = config.MainWindowPosition;
            mainWindow.ClientDisconnectDialog = clientDisconnectDialog;
            mainWindow.InfoWindow             = infoWindow;

            // Create new connection dialog
            clientConnectingDialog = gameObject.AddComponent <ClientConnectingDialog> ();

            // Main window events
            mainWindow.OnStartServerPressed += (s, e) => StartServer();
            mainWindow.OnStopServerPressed  += (s, e) => {
                server.Stop();
                clientConnectingDialog.Close();
            };
            mainWindow.OnHide += (s, e) => {
                config.Load();
                config.MainWindowVisible = false;
                config.Save();
            };
            mainWindow.OnShow += (s, e) => {
                config.Load();
                config.MainWindowVisible = true;
                config.Save();
            };
            mainWindow.OnMoved += (s, e) => {
                config.Load();
                var window = s as MainWindow;
                config.MainWindowPosition = window.Position;
                config.Save();
            };

            // Info window events
            infoWindow.OnHide += (s, e) => {
                config.Load();
                config.InfoWindowVisible = false;
                config.Save();
            };
            infoWindow.OnShow += (s, e) => {
                config.Load();
                config.InfoWindowVisible = true;
                config.Save();
            };
            infoWindow.OnMoved += (s, e) => {
                config.Load();
                var window = s as InfoWindow;
                config.InfoWindowPosition = window.Position;
                config.Save();
            };

            // Server events
            server.OnClientRequestingConnection += (s, e) => {
                if (config.AutoAcceptConnections)
                {
                    e.Request.Allow();
                }
                else
                {
                    clientConnectingDialog.OnClientRequestingConnection(s, e);
                }
            };


            // Add a button to the applauncher
            mainWindow.Closable = true;
            textureOnline       = GameDatabase.Instance.GetTexture("kRPC/icons/applauncher-online", false);
            textureOffline      = GameDatabase.Instance.GetTexture("kRPC/icons/applauncher-offline", false);
            GameEvents.onGUIApplicationLauncherReady.Add(OnGUIApplicationLauncherReady);
            GameEvents.onGUIApplicationLauncherDestroyed.Add(OnGUIApplicationLauncherDestroyed);
            server.OnStarted += (s, e) => {
                if (applauncherButton != null)
                {
                    applauncherButton.SetTexture(textureOnline);
                }
            };
            server.OnStopped += (s, e) => {
                if (applauncherButton != null)
                {
                    applauncherButton.SetTexture(textureOffline);
                }
            };
        }
示例#8
0
        private async void ShowCellValue(object sender, MouseButtonEventArgs e)
        {
            Label cell = (Label)sender;
            int col = (int)cell.GetValue(Grid.ColumnProperty);
            int row = (int)cell.GetValue(Grid.RowProperty);
            if (schedule.partSchedule[row - ROW_HEADER, col - COLUMN_HEADER] != null)
            {
                ClassRoom room = schedule.GetClassRoom(schedule.partSchedule[row - ROW_HEADER, col - COLUMN_HEADER]);
                string teacher = schedule.partSchedule[row - ROW_HEADER, col - COLUMN_HEADER].Teacher.Length > 0 ?
                    schedule.partSchedule[row - ROW_HEADER, col - COLUMN_HEADER].Teacher[0].Name :
                    "";
                var infoWindow = new InfoWindow
                {
                    Message = { Text = String.Format("Пара: {0}\nАудитория: {1} (корпус {2})\nПреподаватель: {3}",
                                        schedule.partSchedule[row - ROW_HEADER, col - COLUMN_HEADER].Name,
                                        room.Number, room.Housing,
                                        teacher) }
                };

                await DialogHost.Show(infoWindow, "MandarinHost");
            }
            else
            {
                var infoWindow = new InfoWindow
                {
                    Message = { Text = "Пусто" }
                };

                await DialogHost.Show(infoWindow, "MandarinHost");
            }
        }
 private void infoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     InfoWindow Info = new InfoWindow();
     Info.Show();
 }
示例#10
0
 //zie comment boven createSelectionBar
 void DestroySelectionStuff()
 {
     //Destroy (infoWindowGO);
     Destroy(selectionBar);
     infoW = null;
 }
示例#11
0
        private async void ChangeCoursOrFaculty()
        {
            if (coursComboBox.SelectedIndex != -1 && facultComboBox.SelectedIndex != -1 && facultComboBox.SelectedItem != null)
            {
                GetScheduleForFacult();
                CreateTimeTable();

                if (schedule.partSchedule.GetLength(1) == 0)
                {
                    var infoWindow = new InfoWindow
                    {
                        Message = { Text = "Не найдено ни 1-ой группы относящихся к "+(coursComboBox.SelectedIndex+1)+" курсу " +facultComboBox.SelectedItem.ToString()+" факультета. \n"+
                               "Убедитесь что вы правильно распредилили группы в настройках"}
                    };
                    await DialogHost.Show(infoWindow, "MandarinHost");
                }
                infoClassTextbox.Text = "";
                InfoTeachersListbox.Items.Clear();
                InfoGrouplistView.Items.Clear();
                ClassRoomlistView.Items.Clear();
                TimeTextBox.Text = "";
                btnRemove.IsEnabled = false;

            }
        }
        private void OnInfoClick(object sender, System.Windows.RoutedEventArgs e)
        {
            InfoWindow info = new InfoWindow();

            info.ShowDialog();
        }
    public static void Reset()
    {
        InfoWindow iw = GetInstance();

        iw.Clear();
    }
示例#14
0
        private async void btnStep3Next_Click(object sender, RoutedEventArgs e)
        {
            if (!VerifyTBConnectString())
            {
                var infoWindow = new InfoWindow
                {
                    Message = { Text = "Вы не заполнили строки подключения" }
                };

                await DialogHost.Show(infoWindow, "BaseWizardHost");
                return;
            }
            if (!VerifyConnectString())
            {
                var infoWindow = new InfoWindow
                {
                    Message = { Text = "Возникли проблемы с подключением" }
                };

                await DialogHost.Show(infoWindow, "BaseWizardHost");
                return;
            }
            tabControl.SelectedIndex = 3;
            if (!CreateEstorage())
            {
                var infoWindow = new InfoWindow
                {
                    Message = { Text = "Возникли проблемы с преобразованием данных" }
                };

                await DialogHost.Show(infoWindow, "BaseWizardHost");
                tabControl.SelectedIndex = 2;
                return;
            }
            step4lbstart.Content = "1.Выгрузка начата:" + DateTime.Now;
            step4lbrezult.Content = "Текущий статус:Выполняется";
        }
示例#15
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            ScreenService.Instance.GraphicsDevice.Viewport = ScreenService.Instance.DefaultScreenCamera.CurrentViewport;
            spriteBatch.Begin(
                SpriteSortMode.FrontToBack, // this is also the order for building the screen.
                null,
                SamplerState.PointClamp,
                null,
                null,
                null,
                ScreenService.Instance.DefaultScreenCamera.TransformMatrix);
            base.Draw(spriteBatch);

            if (!Images.Any())
            {
                Messages.Add("no image received from server");
            }
            foreach (var img in Images.ToList())
            {
                img.Draw(spriteBatch);
            }

            if (!InventoryImages.Any())
            {
                Messages.Add("no inventory image received from server");
            }
            foreach (var img in InventoryImages.ToList())
            {
                img.Draw(spriteBatch);
            }

            MultiplayerText.Draw(spriteBatch);
            HealthImage.Draw(spriteBatch);
            SpeedImage.Draw(spriteBatch);
            StrenghImage.Draw(spriteBatch);
            DialogImage.Draw(spriteBatch);
            CursorImage.Draw(spriteBatch);

            //LerpMouseImage.Draw(spriteBatch);

            if (InfoWindow?.IsVisible == true)
            {
                InfoWindow?.Draw(spriteBatch);
            }

            if (DialogWindow?.IsVisible == true)
            {
                DialogWindow?.Draw(spriteBatch);
            }

            if (InventoryWindow?.IsVisible == true)
            {
                InventoryWindow.Draw(spriteBatch);
            }

            if (CharacterWindow?.IsVisible == true)
            {
                MoneyCount.Draw(spriteBatch);
                CharacterWindow?.Draw(spriteBatch);
            }

            if (CharacterWindow?.IsVisible == true)
            {
                CharacterWindow?.Draw(spriteBatch);
            }

            if (ChatWindow?.IsVisible == true)
            {
                ChatWindow?.Draw(spriteBatch);
            }

            spriteBatch.End();
        }
示例#16
0
        private async void btnStep2Next_Click(object sender, RoutedEventArgs e)
        {
            if (rbStep2my.IsChecked == true)
            {
                repository = Code.StorageLoader.GetRepository(step2tbSelect.Text);
                if (repository == null)
                {
                    var infoWindow = new InfoWindow
                    {
                        Message = { Text = "Данный dll файл не подходит!!!" }
                    };

                    await DialogHost.Show(infoWindow, "BaseWizardHost");
                    return;
                }
                if (!FillingConnectString())
                {
                    var infoWindow = new InfoWindow
                    {
                        Message = { Text = "Проблема с формированием строк подключения!!!" }
                    };

                    await DialogHost.Show(infoWindow, "BaseWizardHost");
                    return;
                }
                tabControl.SelectedIndex = 2;
            }
            else
            {
                Code.CurrentBase.CreateBase();               
                var dialogWindow = new DialogWindow
                {
                    Message = { Text = "Хотите сохранить результат?" }
                };

                object result = await DialogHost.Show(dialogWindow, "BaseWizardHost");
                if ((bool)result == true)
                {
                    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                    saveFileDialog1.Filter = "DB files (*.mandarin|*.mandarin";
                    saveFileDialog1.FilterIndex = 2;
                    saveFileDialog1.RestoreDirectory = true;
                    if (saveFileDialog1.ShowDialog() == true)
                    {
                        Code.CurrentBase.SaveBase(saveFileDialog1.FileName);
                    }
                }
                this.Closing -= Window_Closing;
                Close();

            }
        }
示例#17
0
        public void Notify()
        {
            if (CommonFunctions.UserSettings.ReceiveNotifications)
            {
                if (CommonFunctions.UserSettings.EmailNotifications)
                {
                    GetEmailHtml();

                    if (!string.IsNullOrWhiteSpace(this.emailHtml))
                    {
                        bool htmlUpdated = FillHtml();

                        if (htmlUpdated)
                        {
                            UserCredential credentials = GetGmailCredentials();

                            if (credentials != null)
                            {
                                SendEmail(credentials);
                            }
                            else
                            {
                                //Purge token so they can try authenticating again
                                PurgeUserToken();

                                StringBuilder message = new StringBuilder();
                                message.AppendLine("Unable to get Gmail credentials.");
                                message.AppendLine("Your user token has now been reset.\n");
                                message.AppendLine("Please try again.");

                                InfoWindow badCredentialsWindow = new InfoWindow("Error Sending Email", message.ToString());

                                if (badCredentialsWindow.ShowDialog() == true)
                                {
                                }
                            }
                        }
                        else
                        {
                            CommonFunctions.Log.Warn("Unable to update email html");
                        }
                    }
                    else
                    {
                        CommonFunctions.Log.Warn("Unable to create email html");
                    }
                }

                if (CommonFunctions.UserSettings.TextNotifications)
                {
                    UserCredential credentials = GetGmailCredentials();

                    if (credentials != null)
                    {
                        SendText(credentials);
                    }
                    else
                    {
                        //Purge token so they can try authenticating again
                        PurgeUserToken();

                        StringBuilder message = new StringBuilder();
                        message.AppendLine("Unable to get Gmail credentials.");
                        message.AppendLine("Your user token has now been reset.\n");
                        message.AppendLine("Please try again.");

                        InfoWindow badCredentialsWindow = new InfoWindow("Error Sending Text Message", message.ToString());

                        if (badCredentialsWindow.ShowDialog() == true)
                        {
                        }
                    }
                }


                if (CommonFunctions.UserSettings.PopupNotifications)
                {
                    OpenPopup();
                }

                //Finally, change the last notified date
                UpdateLastNotifiedDate();
            }
        }
示例#18
0
 public void OpenInfoWindow(Vessel vessel)
 {
     infoWindow = PTGUI_Info.Instance.OperWindow(vessel);
 }
 void InfoProvider.bindInfoWindow(InfoWindow infoWindow)
 {
     this.infoWindow = infoWindow;
 }
示例#20
0
 private void Awake()
 {
     instance = this;
 }
示例#21
0
        private void OnGUI()
        {
            if (_window == null)
            {
                _window = this;

                _window.titleContent.image = ToolIcon;
            }

            EditorGUILayout.BeginVertical(BOX);

            GUILayout.Space(2);

            #region Help Button

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();

            if (_helpBttn == null)
            {
                _helpBttn = EditorGUIUtility.Load(HELPICON) as Texture2D;
            }

            var helpStyle = new GUIStyle(GUIStyle.none)
            {
                fontStyle = FontStyle.Bold
            };
            var helpContent = new GUIContent(string.Empty, _helpBttn, HELPTOOLTIP);

            if (GUILayout.Button(helpContent, helpStyle, GUILayout.Width(15)))
            {
                if (_infoWindow == null)
                {
                    _infoWindow = InfoWindow.InfoInit();
                }
            }

            GUILayout.Space(3);
            EditorGUILayout.EndHorizontal();

            #endregion

            GUILayout.Space(1);

            #region Fav or Recent Tab

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            var tabSkin = new GUIStyle(GUI.skin.button)
            {
                alignment = TextAnchor.MiddleCenter,
                fontSize  = 12,
                fontStyle = FontStyle.Bold
            };

            var recentBttn   = new GUIContent(RECENT, RECENTBUTTONTOOLTIP);
            var favoriteBttn = new GUIContent(FAVORITES, FAVORITESBUTTONTOOLTIP);
            RecentSceneManager.recentOrFav = GUILayout.SelectionGrid(RecentSceneManager.recentOrFav,
                                                                     new[] { recentBttn, favoriteBttn }, 2, tabSkin, GUILayout.MaxWidth(200));
            EditorGUILayout.Space();
            EditorGUILayout.EndHorizontal();

            #endregion

            GUILayout.Label("", GUI.skin.horizontalSlider);

            _scrollPos = GUILayout.BeginScrollView(_scrollPos);
            if (RecentSceneManager.recentOrFav == 0)
            {
                var labelWidth = 0f;
                foreach (var scene in RecentSceneManager.recentScenes)
                {
                    var textDimensions = GUI.skin.label.CalcSize(new GUIContent(scene));
                    if (textDimensions.x > labelWidth)
                    {
                        labelWidth = textDimensions.x;
                    }
                }

                for (var i = 0; i < RecentSceneManager.recentScenes.Count; i++)
                {
                    i = DisplayObject(i, RecentSceneManager.recentScenes);
                }

                if (RecentSceneManager.recentScenes.Count > 0)
                {
                    var spaceSize = RecentSceneManager.keepTrackOfRecentScenes + 1 -
                                    RecentSceneManager.recentScenes.Count;
                    spaceSize *= 28;
                    GUILayout.Space(pixels: spaceSize);

                    EditorGUILayout.EndScrollView();
                    if (GUILayout.Button(CLEARRECENT))
                    {
                        for (var j = 0; j < RecentSceneManager.recentScenes.Count; j++)
                        {
                            RecentSceneManager.recentScenes[j] = null;
                            InitializeSceneManager.RemoveKey(Application.productName + RECENTSCENES + j);
                        }
                    }
                }
                else
                {
                    EditorGUILayout.EndScrollView();
                    GUILayout.Space(20);
                    var centerBoldLabel = new GUIStyle(EditorStyles.label)
                    {
                        alignment = TextAnchor.MiddleCenter,
                        fontStyle = FontStyle.Bold
                    };
                    GUILayout.Label(NORECENT, centerBoldLabel);
                    GUILayout.Space(130);

                    if (GUILayout.Button(RecentSceneManager.CLOSE))
                    {
                        _window.Close();
                    }
                }
            }
            else
            {
                var labelWidth = 0f;
                foreach (var scene in FavoriteScenesManager.favoritedScenes)
                {
                    var textDimensions = GUI.skin.label.CalcSize(new GUIContent(scene));
                    if (textDimensions.x > labelWidth)
                    {
                        labelWidth = textDimensions.x;
                    }
                }

                for (var i = 0; i < FavoriteScenesManager.favoritedScenes.Count; i++)
                {
                    i = DisplayObject(i, FavoriteScenesManager.favoritedScenes);
                }

                if (FavoriteScenesManager.favoritedScenes.Count > 0)
                {
                    var spaceSize = RecentSceneManager.keepTrackOfRecentScenes + 1 -
                                    RecentSceneManager.recentScenes.Count;
                    spaceSize *= 28;
                    GUILayout.Space(pixels: spaceSize);

                    EditorGUILayout.EndScrollView();
                    var clearFavBttn = new GUIContent(CLEARFAVORITES, CLEARFAVTOOLTIP);
                    if (GUILayout.Button(clearFavBttn))
                    {
                        if (EditorUtility.DisplayDialog(CLEARFAVCONFIRM, CLEARFAVMSG,
                                                        RecentSceneManager.YES, RecentSceneManager.NO))
                        {
                            for (var j = 0; j < FavoriteScenesManager.favoritedScenes.Count; j++)
                            {
                                FavoriteScenesManager.favoritedScenes[j] = null;
                                InitializeSceneManager.RemoveKey(Application.productName + FAVORITESCENES + j);
                            }

                            FavoriteScenesManager.favoritedScenes.Clear();
                        }
                    }
                }
                else
                {
                    EditorGUILayout.EndScrollView();
                    GUILayout.Space(20);
                    var centerBoldLabel = new GUIStyle(EditorStyles.label)
                    {
                        alignment = TextAnchor.MiddleCenter,
                        fontStyle = FontStyle.Bold
                    };
                    GUILayout.Label(NOFAVORITES, centerBoldLabel);
                    GUILayout.Space(130);

                    if (GUILayout.Button(RecentSceneManager.CLOSE))
                    {
                        _window.Close();
                    }
                }
            }

            EditorGUILayout.EndVertical();
        }
示例#22
0
        private async void miDBSave_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentBase.BaseIsLoaded())
            {
                try
                {
                    CurrentBase.SaveBase();
                    var infoWindow = new InfoWindow
                    {
                        Message = { Text = "База успешно сохранена" }
                    };
                    await DialogHost.Show(infoWindow, "MandarinHost");
                }
                catch
                {
                    var infoWindow = new InfoWindow
                    {
                        Message = { Text = "Ошибка сохранения базы" }
                    };
                    await DialogHost.Show(infoWindow, "MandarinHost");
                }

            }
        }
        /// <summary>
        /// The connection method to Storage4 (modal).
        /// Called from an event handler lstFriends_MouseDoubleClick.
        /// </summary>
        /// <param name="context">The context of the interaction with the database.</param>
        /// <param name="userId">User ID.</param>
        /// <param name="services">Services class object to check - whether our services work.</param>
        /// <param name="logging">Logging class object to create the log.</param>
        /// <param name="friend">User friend.</param>
        /// <param name="lstFriends">ListBox control where your friends list will be added.</param>
        /// <param name="frm">Instance a modal window.</param>
        public void ConnectToServer4(Storage4Context context, int userId, Services services, Logging logging, Friend friend, System.Windows.Controls.ListBox lstFriends, InfoWindow frm)
        {
            RedisOrSQLStorage4(context, userId, services, logging, frm);

            var queryFriendsStorage = context.Friends.Where(x => x.User_Id == userId);
            var friends = queryFriendsStorage.ToList();
            foreach (var f in friends)
            {
                if (f.Friend_Id < 100000)
                {
                    using (var storage1Context = new Storage1Context())
                    {
                        frm.FriendsParam = friend.FindFriendsStorage1(storage1Context, f, frm);
                    }
                }
                else if (f.Friend_Id > 100000 && f.Friend_Id < 200000)
                {
                    using (var storage2Context = new Storage2Context())
                    {
                        frm.FriendsParam = friend.FindFriendsStorage2(storage2Context, f, frm);
                    }
                }
                else if (f.Friend_Id > 200000 && f.Friend_Id < 300000)
                {
                    using (var storage3Context = new Storage3Context())
                    {
                        frm.FriendsParam = friend.FindFriendsStorage3(storage3Context, f, frm);
                    }
                }
                else if (f.Friend_Id > 300000 && f.Friend_Id < 400000)
                {
                    frm.FriendsParam = friend.FindFriendsStorage4(context, f, frm);
                }
                else if (f.Friend_Id > 400000 && f.Friend_Id < 500000)
                {
                    using (var storage5Context = new Storage5Context())
                    {
                        frm.FriendsParam = friend.FindFriendsStorage5(storage5Context, f, frm);
                    }
                }
            }
        }
示例#24
0
        private async void miDBSaveAs_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "DB files (*.mandarin|*.mandarin";
            saveFileDialog.FilterIndex = 2;
            saveFileDialog.RestoreDirectory = true;
            if (saveFileDialog.ShowDialog() == true)
            {
                try
                {
                    CurrentBase.SaveBase(saveFileDialog.FileName);
                    var infoWindow = new InfoWindow
                    {
                        Message = { Text = "База успешно сохранена" }
                    };
                    await DialogHost.Show(infoWindow, "MandarinHost");
                    CurrentBase.OpenBase(CurrentBase.LoadBase(saveFileDialog.FileName));
                }
                catch
                {
                    var infoWindow = new InfoWindow
                    {
                        Message = { Text = "Ошибка сохранения базы" }
                    };
                    await DialogHost.Show(infoWindow, "MandarinHost");
                    return;
                }

            }

        }
示例#25
0
        public List <InfoWindow> GetOrderListDetails(int orderType_id)
        {
            OrderQuery OrderQuery = new OrderQuery(language);


            System.Data.DataTable  dataTable       = conn_db.ReadTable(OrderQuery.GetOrderListDetailsByType(orderType_id));
            System.Data.DataTable  OrderList       = conn_db.ReadTable(OrderQuery.GetOrderListTitle(orderType_id));
            orderListDetail        orderListDetail = new  orderListDetail();
            List <orderListDetail> orderListDetails;


            InfoWindow        info;
            List <InfoWindow> infoWindows = new List <InfoWindow>();


            if (dataTable.Rows.Count == 0)
            {
                throw new EmptyViewException(language);
            }
            foreach (System.Data.DataRow rowList in OrderList.Rows)
            {
                orderListDetails = new List <orderListDetail>();
                info             = new InfoWindow();
                info.List_id     = Convert.ToInt32(rowList["ID"]);
                if (language == Messages.language.ar.ToString())
                {
                    info.Listname = rowList["LISTNAME_AR"].ToString();
                }
                else
                {
                    info.Listname = rowList["LISTNAME_EN"].ToString();
                }


                foreach (System.Data.DataRow row in dataTable.Rows)
                {
                    orderListDetail = new orderListDetail();
                    if (info.List_id == Convert.ToInt32(row["ORDERLIST_ID"]))
                    {
                        if (language == Messages.language.ar.ToString())
                        {
                            orderListDetail = new orderListDetail {
                                id = Convert.ToInt32(row["ID"]), contentName = row["CONTENTNAME_AR"].ToString()
                            }
                        }
                        ;
                        else
                        {
                            orderListDetail = new orderListDetail {
                                id = Convert.ToInt32(row["ID"]), contentName = row["CONTENTNAME_EN"].ToString()
                            }
                        };


                        orderListDetails.Add(orderListDetail);
                    }
                }


                info.contents = orderListDetails;

                infoWindows.Add(info);
            }
            return(infoWindows);
        }
示例#26
0
 private async void OpenScheduleFromFile()
 {
     OpenFileDialog openFile = new OpenFileDialog();
     openFile.Filter = "Mandarin Schedule File(*.msf) | *.msf";
     if (openFile.ShowDialog() == false)
     {
         return;
     }
     try
     {
         CurrentSchedule.LoadSchedule(openFile.FileName);
         OpenScheduleEditor();
         misheduleExportFaculty.IsEnabled = false;
     }
     catch
     {
         var infoWindow = new InfoWindow
         {
             Message = { Text = "Не удалось открыть" }
         };
         await DialogHost.Show(infoWindow, "MandarinHost");
         return;
     }
 }
示例#27
0
        private void SaveExcel()
        {
            Code.ScheduleExcel excel = new Code.ScheduleExcel(filepath, schedule, schedule.EStorage);
            excel.LoadPartScheduleExcel(schedule.Groups);
            this.Dispatcher.Invoke(new Action(async delegate ()
            {
                var infoWindow = new InfoWindow
                {
                    Message = { Text = "Расписание сформировано:\n" + filepath }
                };
                await DialogHost.Show(infoWindow, "MandarinHost");

            }));
        }
示例#28
0
        private async void SaveScheduleAs()
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.Filter = "Mandarin Schedule File(*.msf) | *.msf";
            saveFileDialog.FilterIndex = 2;
            saveFileDialog.RestoreDirectory = true;
            if (saveFileDialog.ShowDialog() == true)
            {
                if (CurrentSchedule.ScheduleIsLoaded())
                {
                    try
                    {
                        CurrentSchedule.SaveSchedule(saveFileDialog.FileName);
                        var infoWindow = new InfoWindow
                        {
                            Message = { Text = "Сохранение прошло успешно" }
                        };
                        await DialogHost.Show(infoWindow, "MandarinHost");

                    }
                    catch
                    {
                        var infoWindow = new InfoWindow
                        {
                            Message = { Text = "Не удалось сохранить" }
                        };
                        await DialogHost.Show(infoWindow, "MandarinHost");
                        return;
                    }
                }
            }
        }
 void SaveExcel()
 {
     Code.ScheduleExcel excel = new Code.ScheduleExcel(filepath, schedule, schedule.EStorage);
     excel.LoadPartScheduleExcel(checkedsubgroups);
     this.Dispatcher.Invoke(new Action(async delegate ()
     {
         var infoWindow = new InfoWindow
         {
             Message = { Text = "Расписание сформировано:\n" + filepath }
         };
         await DialogHost.Show(infoWindow, "ScheduleSubGroupsForExcel");
         btnSave.IsEnabled = true;
     }));
 }
示例#30
0
        private async void SaveSchedule()
        {
            try
            {
                CurrentSchedule.SaveSchedule();
                var infoWindow = new InfoWindow
                {
                    Message = { Text = "Сохранено" }
                };
                await DialogHost.Show(infoWindow, "MandarinHost");
                return;

            }
            catch
            {
                var infoWindow = new InfoWindow
                {
                    Message = { Text = "Не удалось сохранить" }
                };
                await DialogHost.Show(infoWindow, "MandarinHost");
                return;
            }
        }
        private bool VerifyValidSettings()
        {
            bool valid = true;

            try
            {
                bool emailEnabled = email_chbx.IsChecked ?? false;
                bool textEnabled  = textMessages_chbx.IsChecked ?? false;

                bool isEmailAddressEntered = !string.IsNullOrWhiteSpace(email_txtbx.Text);

                //Email enabled but there is no email address inputted
                if (emailEnabled && !isEmailAddressEntered)
                {
                    valid = false;

                    StringBuilder message = new StringBuilder();
                    message.AppendLine("Email notifications are enabled but no email address has been entered.\n");
                    message.AppendLine("Please enter your email address in the email address textbox.");

                    InfoWindow emailInfo = new InfoWindow("Email Address Error", message.ToString());
                    if (emailInfo.ShowDialog() == true)
                    {
                        //close window
                    }
                }

                bool isPhoneNumberEntered     = !string.IsNullOrWhiteSpace(phoneNumber_txtbx.Text);
                bool isCarrierSelectedEntered = carrier_cmbobox.SelectedIndex != 0;

                //Text messages enabled but there is no phone number and/or carrier selected
                if ((textEnabled && !isPhoneNumberEntered) || textEnabled && !isCarrierSelectedEntered)
                {
                    if (!isPhoneNumberEntered && isCarrierSelectedEntered)
                    {
                        StringBuilder message = new StringBuilder();
                        message.AppendLine("Text notifications are enabled but no phone number has been entered.\n");
                        message.AppendLine("Please enter your phone number in the phone number textbox.");

                        InfoWindow textInfo = new InfoWindow("Text Message Phone Number Error", message.ToString());
                        if (textInfo.ShowDialog() == true)
                        {
                            //close window
                        }
                    }
                    else if (isPhoneNumberEntered && !isCarrierSelectedEntered)
                    {
                        StringBuilder message = new StringBuilder();
                        message.AppendLine("Text notifications are enabled but no carrier has been selected.\n");
                        message.AppendLine("Please select your carrier from the carrier drop down.");

                        InfoWindow textInfo = new InfoWindow("Text Message Carrier Error", message.ToString());
                        if (textInfo.ShowDialog() == true)
                        {
                            //close window
                        }
                    }
                    else //both are left blank
                    {
                        StringBuilder message = new StringBuilder();
                        message.AppendLine("Text notifications are enabled but no phone number has been entered and the carrier is left blank.\n");
                        message.AppendLine("Please enter your phone number in the phone number textbox and select your carrier from the carrier drop down.");

                        InfoWindow textInfo = new InfoWindow("Text Message Error", message.ToString());
                        if (textInfo.ShowDialog() == true)
                        {
                            //close window
                        }
                    }


                    valid = false;
                }
            }
            catch (Exception ex)
            {
                CommonFunctions.Log.Error("Error validating settings", ex);
                valid = false;
            }
            return(valid);
        }
示例#32
0
 private async void OpenFactorSettings()
 {
     if (CurrentBase.BaseIsLoaded())
     {
         miMain.Header = "Закрыть";
         contentControl.Content = new FactorSettingsForm();
     }
     else
     {
         var infoWindow = new InfoWindow
         {
             Message = { Text = "База данных не загружена" }
         };
         await DialogHost.Show(infoWindow, "MandarinHost");
     }
 }
示例#33
0
        public static void Show(this InfoWindow _infoWindow, MapPoint anchorPoint)
        {
            if (_infoWindow != null)
            {
                _infoWindow.Anchor = anchorPoint;

                if (_infoWindow.Placement == InfoWindow.PlacementMode.Auto)
                {
                    _infoWindow.IsOpen = true;
                    return;
                }

                Map map = _infoWindow.Map;
                _infoWindow.IsOpen = false;
                _infoWindow.UpdateLayout();

                // Give the Layout time to size/arrange
                _infoWindow.Dispatcher.BeginInvoke(() =>
                {
                    //if (_infoWindow.Placement != InfoWindow.PlacementMode.Auto)
                    //{
                    if (double.IsNaN(_infoWindow.ActualHeight) || _infoWindow.ActualHeight == 0.0 ||
                        double.IsNaN(_infoWindow.ActualWidth) || _infoWindow.ActualWidth == 0.0)
                    {
                        return;
                    }
                    double windowHeight     = _infoWindow.ActualHeight;
                    double windowWidth      = _infoWindow.ActualWidth;
                    Point point             = map.MapToScreen(_infoWindow.Anchor);
                    MapPoint mapTopLeft     = map.ScreenToMap(new Point(point.X - windowWidth / 2.0, point.Y - windowHeight));
                    MapPoint mapBottomRight = map.ScreenToMap(new Point(point.X + windowWidth / 2.0, point.Y));
                    double mapWindowHeight  = mapTopLeft.Y - mapBottomRight.Y;
                    double mapWindowWidth   = mapBottomRight.X - mapTopLeft.X;

                    MapPoint newCenter = new MapPoint(map.Extent.XMin + ((map.Extent.XMax - map.Extent.XMin) / 2.0),
                                                      map.Extent.YMin + ((map.Extent.YMax - map.Extent.YMin) / 2.0));
                    bool panRequired = false;
                    double yDiff     = (mapTopLeft.Y + mapWindowHeight * 0.3) - map.Extent.YMax;
                    if (yDiff > 0)
                    {
                        newCenter.Y += yDiff;
                        panRequired  = true;
                    }

                    double xMinDiff = map.Extent.XMin - (mapTopLeft.X - mapWindowWidth * 0.2);
                    if (xMinDiff > 0)
                    {
                        newCenter.X -= xMinDiff;
                        panRequired  = true;
                    }
                    else
                    {
                        double xMaxDiff = (mapBottomRight.X + mapWindowWidth * 0.2) - map.Extent.XMax;
                        if (xMaxDiff > 0)
                        {
                            newCenter.X += xMaxDiff;
                            panRequired  = true;
                        }
                    }
                    if (panRequired)
                    {
                        map.PanTo(newCenter);
                    }
                    //}

                    _infoWindow.IsOpen = true;
                });
            }
        }
示例#34
0
 private async void OpenFacultiesSettings()
 {
     if (CurrentBase.BaseIsLoaded())
     {
         FacultyAndGroupsForm facult = new FacultyAndGroupsForm();
         facult.ShowDialog();
     }
     else
     {
         var infoWindow = new InfoWindow
         {
             Message = { Text = "База данных не загружена" }
         };
         await DialogHost.Show(infoWindow, "MandarinHost");
     }
 }
        private void DoSearch(string s)
        {
            WebResponse response = null;
            string      can      = "";

            foreach (char ch in s)
            {
                int hex = ch;
                can += "%" + Convert.ToString(hex, 16);
            }
            try
            {
                // 使用 KingDraw 的 API 将 SMILES 转换为图片
                response = WebRequest.Create("http://baike.kingdraw.com/api/smilesToImage?smiles=" + can).GetResponse();
            }
            catch (Exception)
            {
                Height = 85;
                this.FindControl <Avalonia.Controls.Image>("img").IsVisible = false;
                this.FindControl <Button>("save").IsVisible    = false;
                this.FindControl <TextBlock>("err").IsVisible  = false;
                this.FindControl <TextBlock>("nerr").IsVisible = true;
                return;
            }
            try
            {
                Stream stream = response.GetResponseStream();
                System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
                bitmap  = new Bitmap(image);
                nbitmap = (Bitmap)bitmap.Clone();
                if (image.Width > Width - 20)
                {
                    bitmap = InfoWindow.ZoomImage(bitmap, (int)(image.Height * (Width - 20) / image.Width), (int)(Width - 20));
                }
                Color clr;
                for (int x = 0; x < bitmap.Width; ++x)
                {
                    for (int y = 0; y < bitmap.Height; ++y)
                    {
                        clr = bitmap.GetPixel(x, y);
                        bitmap.SetPixel(x, y, Color.FromArgb(Math.Max(40, 255 - clr.R), Math.Max(40, 255 - clr.G), Math.Max(40, 255 - clr.B)));
                    }
                }
                Stream str = new MemoryStream();
                bitmap.Save(str, ImageFormat.Png);
                str.Position = 0;
                Avalonia.Media.Imaging.Bitmap bitmap1 = new Avalonia.Media.Imaging.Bitmap(str);
                this.FindControl <Avalonia.Controls.Image>("img").Source = bitmap1;
                Height  = 50;
                Height += bitmap1.Size.Height + 50;
                this.FindControl <Avalonia.Controls.Image>("img").Height    = bitmap1.Size.Height;
                this.FindControl <Avalonia.Controls.Image>("img").Width     = bitmap1.Size.Width;
                this.FindControl <Avalonia.Controls.Image>("img").IsVisible = true;
                this.FindControl <Button>("save").IsVisible    = true;
                this.FindControl <TextBlock>("err").IsVisible  = false;
                this.FindControl <TextBlock>("nerr").IsVisible = false;
            } catch (Exception)
            {
                Height = 85;
                this.FindControl <Avalonia.Controls.Image>("img").IsVisible = false;
                this.FindControl <Button>("save").IsVisible    = false;
                this.FindControl <TextBlock>("err").IsVisible  = true;
                this.FindControl <TextBlock>("nerr").IsVisible = false;
            }
        }
示例#36
0
 private async void OpenCoreRunner()
 {
     if (CurrentBase.BaseIsLoaded())
     {
         if (CurrentBase.EStorage.Classes.Length > 0)
         {
             contentControl.Content = new CoreRunnerForm();
         }
         else
         {
             var infoWindow = new InfoWindow
             {
                 Message = { Text = "В базе данных отсутствуют пары.\n" +
                                 "Генерация расписания невозможна." }
             };
             await DialogHost.Show(infoWindow, "MandarinHost");
         }
     }
     else
     {
         var infoWindow = new InfoWindow
         {
             Message = { Text = "База данных не загружена" }
         };
         await DialogHost.Show(infoWindow, "MandarinHost");
     }
 }
    public void SetData(string s)
    {
        if (showingCheckResult)
        {
            InfoWindow.Reset();
            showingCheckResult = false;
        }

        string[] data      = s.Split(',');
        char[]   unit      = { 'M' };
        float    latitude  = float.Parse(data[4]);
        float    longitude = float.Parse(data[5]);
        float    altitude  = float.Parse(data[6].TrimEnd(unit));

        // 前回のGPS情報と比較して一致したらreturn
        if ((latitude == checkLatitude) &&
            (longitude == checkLongitude) &&
            (altitude == checkAltitude))
        {
//            return;
        }
        checkLatitude  = latitude;
        checkLongitude = longitude;
        checkAltitude  = altitude;

        // 重複データではないので描画
        count++;
        lastTime        = currentTime;
        lastAltitude    = currentAltitude;
        currentAltitude = altitude;

        float  rssi    = float.Parse(data[2]);
        string strTime = data[3];

        string[] dateTime = strTime.Split(' ');
        string   strDate;

        string[] timeToken;
        if (dateTime.Length == 2)
        {
            strDate   = dateTime[0];
            timeToken = dateTime[1].Split(':');
        }
        else
        {
            strDate   = System.DateTime.UtcNow.ToString("yyyy-MM-dd");
            timeToken = strTime.Split(':');
        }

        int iHour   = int.Parse(timeToken[0]);
        int iMinute = int.Parse(timeToken[1]);
        int iSecond = int.Parse(timeToken[2]);


        currentTime = iHour * 3600
                      + iMinute * 60
                      + iSecond;
        if (timeToken[0] == "00")
        {
            if (currentTime < lastTime)
            {
                lastTime -= 3600 * 24;
            }
        }

        strTime = iHour.ToString("00") + ":"
                  + iMinute.ToString("00") + ":"
                  + iSecond.ToString("00");


        float deltaTime = (float)(currentTime - lastTime);

        lastClimingSpeed = climingSpeed;
        if ((deltaTime > 0f) && (deltaTime < 3600f))
        {
            if (currentAltitude == lastAltitude)
            {
                // センサの返す標高が前回と変わらないことがあるので
                // その場合は前回速度を使う
                climingSpeed = lastClimingSpeed;
            }
            else
            {
                climingSpeed = (currentAltitude - lastAltitude) / deltaTime;
            }
        }
        else
        {
            climingSpeed = 0f;
        }

        string sign = " ";

        if (rssi < 0)
        {
            sign = "-";
            rssi = Mathf.Abs(rssi);
        }
        string strCount        = count.ToString("###");
        string strLatitude     = latitude.ToString("###.00000");
        string strLongitude    = longitude.ToString("###.00000");
        string strAltitude     = currentAltitude.ToString("##,###") + " m";
        string strzAltitude    = currentAltitude.ToString("00,000") + " m";
        string strRSSI         = sign + rssi.ToString("###.00 dBm");
        string strzRSSI        = sign + rssi.ToString("000.00 dBm");
        string strClimingSpeed = climingSpeed.ToString("##0.00 m/s");


        // 地図の中心を設定(初回のみ)
        if (!init)
        {
            GeoCalculator.UpdateReferencePos(latitude, longitude);
            mapInitializer.SetMapCenter(latitude, longitude);
            init = true;
        }

        // バルーン位置更新
        mover.SetData(latitude, longitude, currentAltitude, rssi, strTime);

        // バルーンラベル更新
        balloonLabel.SetData(strLatitude, strLongitude, strAltitude, strRSSI);

        // ログウィンドウ更新
        InfoWindow.SetData(strDate + "  " + strTime + "  " + strLatitude + "  " + strLongitude + "  " + strzAltitude);

        // データウィンドウ更新
        dataWindow.SetData(strCount, strTime, strLatitude, strLongitude, strAltitude, strClimingSpeed, strRSSI);

        // 標高グラフ更新
        altitudeGraph.AddPoint(deltaTime, currentAltitude);

        // 上昇速度グラフ更新
        climingSpeedGraph.AddPoint(deltaTime, climingSpeed);

        // モジュールイメージ更新
        moduleImager.SetData(-rssi);

        // 電波拡散表示
        signal.Ping();

        // サウンド更新
        if (cfg.SoundEffect)
        {
            if (!se.isPlaying)
            {
                se.PlayDelayed(0.3f);
            }
        }
    }
示例#38
0
        private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!canClose)
            {
                if (CurrentBase.BaseIsLoaded())
                {
                    e.Cancel = true;
                    var dialogWindow = new DialogCancelWindow
                    {
                        Message = { Text = "Вы хотите сохранить базу перед закрытием приложения?" }
                    };
                    object result = await DialogHost.Show(dialogWindow, "MandarinHost");
                    try
                    {
                        if (result != null)
                        {
                            if ((bool)result == true)
                            {
                                CurrentBase.SaveBase();
                                var infoWindow = new InfoWindow
                                {
                                    Message = { Text = "База успешно сохранена" }
                                };
                                await DialogHost.Show(infoWindow, "MandarinHost");
                            }
                            canClose = true;
                            this.Close();
                        }
                    }
                    catch
                    {
                        var infoWindow = new InfoWindow
                        {
                            Message = { Text = "Ошибка сохранения базы" }
                        };
                        await DialogHost.Show(infoWindow, "MandarinHost");
                    }

                }
            }


        }
示例#39
0
            private void OnGUI()
            {
                EditorGUILayout.BeginVertical(BOX);
                GUILayout.Space(1);

                #region Help Button

                EditorGUILayout.BeginHorizontal();
                var iconStyle = new GUIStyle(GUIStyle.none)
                {
                    padding = new RectOffset(-1, 0, -2, 0)
                };
                GUILayout.Label(ToolIconSmall, iconStyle, GUILayout.Height(17), GUILayout.Width(17));
                EditorGUILayout.Space();

                if (_helpBttn == null)
                {
                    _helpBttn = EditorGUIUtility.Load("_Help") as Texture2D;
                }

                var helpStyle = new GUIStyle(GUIStyle.none)
                {
                    fontStyle = FontStyle.Bold
                };
                var helpContent = new GUIContent(string.Empty, _helpBttn, "Opens Recent Scenes Manager Info");

                if (GUILayout.Button(helpContent, helpStyle, GUILayout.Width(15)))
                {
                    if (_infoWindow == null)
                    {
                        _infoWindow = InfoWindow.InfoInit();
                    }
                }

                GUILayout.Space(1);
                EditorGUILayout.EndHorizontal();

                #endregion

                GUILayout.Space(3);

                var content  = new GUIContent("Max Tracked Scenes");
                var wasTrack = RecentSceneManager.keepTrackOfRecentScenes;
                RecentSceneManager.keepTrackOfRecentScenes =
                    EditorGUILayout.IntSlider(content, RecentSceneManager.keepTrackOfRecentScenes, 2, 20);
                if (wasTrack != RecentSceneManager.keepTrackOfRecentScenes)
                {
                    InitializeSceneManager.SetEditorPrefInt(InitializeSceneManager.TRACKEDCOUNT,
                                                            RecentSceneManager.keepTrackOfRecentScenes);
                    while (RecentSceneManager.recentScenes.Count > RecentSceneManager.keepTrackOfRecentScenes)
                    {
                        var last = RecentSceneManager.recentScenes[RecentSceneManager.recentScenes.Count - 1];
                        if (RecentSceneManager.pathAndScene.ContainsKey(last))
                        {
                            var scene = RecentSceneManager.pathAndScene[last];
                            RecentSceneManager.pathAndScene.Remove(last);
                            scene.ClearImage();
                        }

                        InitializeSceneManager.SetEditorPrefString(
                            $"{Application.productName}{RECENTSCENES}{RecentSceneManager.recentScenes.Count - 1}",
                            string.Empty);

                        RecentSceneManager.recentScenes.Remove(last);
                    }

                    _window.OnGUI();
                }

                EditorGUILayout.Space();

                var trackScenes = RecentSceneManager.trackScenePreview;
                RecentSceneManager.trackScenePreview =
                    EditorGUILayout.Toggle("Track Scene Previews", RecentSceneManager.trackScenePreview);
                if (trackScenes != RecentSceneManager.trackScenePreview)
                {
                    InitializeSceneManager.SetEditorPrefBool(InitializeSceneManager.TRACKSCENEPREVIEW,
                                                             RecentSceneManager.trackScenePreview);
                }

                var trackEdited = RecentSceneManager.trackEditedBy;
                RecentSceneManager.trackEditedBy =
                    EditorGUILayout.Toggle("Track Edited By", RecentSceneManager.trackEditedBy);
                if (trackEdited != RecentSceneManager.trackEditedBy)
                {
                    InitializeSceneManager.SetEditorPrefBool(InitializeSceneManager.TRACKEDITEDBY,
                                                             RecentSceneManager.trackEditedBy);
                }

                EditorGUILayout.Space();

                var close = RecentSceneManager.closeWindowOnLoad;
                RecentSceneManager.closeWindowOnLoad =
                    EditorGUILayout.ToggleLeft("Close Window On Load", RecentSceneManager.closeWindowOnLoad);
                if (close != RecentSceneManager.closeWindowOnLoad)
                {
                    InitializeSceneManager.SetEditorPrefBool(InitializeSceneManager.CLOSEWINDOWONLOAD,
                                                             RecentSceneManager.closeWindowOnLoad);
                }

                EditorGUILayout.Space();
                EditorGUI.BeginDisabledGroup(RecentSceneManager.recentScenes.Count == 0);

                if (GUILayout.Button(CLEARRECENT))
                {
                    for (var j = 0; j < RecentSceneManager.recentScenes.Count; j++)
                    {
                        RecentSceneManager.recentScenes[j] = null;
                        InitializeSceneManager.RemoveKey(Application.productName + RECENTSCENES + j);
                    }
                }

                EditorGUI.EndDisabledGroup();

                EditorGUILayout.EndVertical();
            }
示例#40
0
        internal static void MainWindow_KeysDown(object sender, KeyEventArgs e)
        {
            // Don't allow keys when typing in text
            if (GetMainWindow.TitleText.IsKeyboardFocusWithin)
            {
                return;
            }

            var ctrlDown  = (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
            var altDown   = (Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt;
            var shiftDown = (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;

            #region CroppingKeys

            if (GetCropppingTool != null)
            {
                if (GetCropppingTool.IsVisible)
                {
                    if (e.Key == Key.Escape)
                    {
                        CropFunctions.CloseCrop();
                        e.Handled = true;
                        return;
                    }

                    if (e.Key == Key.Enter)
                    {
                        CropFunctions.PerformCrop();
                        e.Handled = true;
                        return;
                    }
                    e.Handled = true;
                    return;
                }
            }

            #endregion CroppingKeys

            #region Keys where it can be held down

            switch (e.Key)
            {
            case Key.BrowserForward:
            case Key.Right:
            case Key.D:
                if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        if (Properties.Settings.Default.PicGallery == 1)
                        {
                            return;
                        }
                    }
                }
                if (!e.IsRepeat)
                {
                    // Go to first if Ctrl held down
                    if (ctrlDown)
                    {
                        Pic(true, true);
                    }
                    else
                    {
                        Pic();
                    }
                }
                else if (CanNavigate)
                {
                    FastPic(true);
                }
                return;

            case Key.BrowserBack:
            case Key.Left:
            case Key.A:
                if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        if (Properties.Settings.Default.PicGallery == 1)
                        {
                            return;
                        }
                    }
                }
                if (!e.IsRepeat)
                {
                    // Go to last if Ctrl held down
                    if (ctrlDown)
                    {
                        Pic(false, true);
                    }
                    else
                    {
                        Pic(false);
                    }
                }
                else if (CanNavigate)
                {
                    FastPic(false);
                }
                return;

            case Key.PageUp:
                if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        ScrollTo(true, ctrlDown);
                        return;
                    }
                }
                if (Properties.Settings.Default.ScrollEnabled)
                {
                    GetMainWindow.Scroller.ScrollToVerticalOffset(GetMainWindow.Scroller.VerticalOffset - 30);
                }

                return;

            case Key.PageDown:
                if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        ScrollTo(false, (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control);
                        return;
                    }
                }
                if (Properties.Settings.Default.ScrollEnabled)
                {
                    GetMainWindow.Scroller.ScrollToVerticalOffset(GetMainWindow.Scroller.VerticalOffset + 30);
                }

                return;

            case Key.Up:
            case Key.W:
                if (Properties.Settings.Default.ScrollEnabled)
                {
                    if (ctrlDown)
                    {
                        return;
                    }
                    else
                    {
                        GetMainWindow.Scroller.ScrollToVerticalOffset(GetMainWindow.Scroller.VerticalOffset - 30);
                    }
                }
                else if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        if (Properties.Settings.Default.PicGallery == 1)
                        {
                            ScrollTo(false, (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control);
                            return;
                        }
                        else
                        {
                            Pic(false);
                        }
                    }
                    else
                    {
                        Rotate(false);
                    }
                }
                else
                {
                    Rotate(false);
                }

                return;

            case Key.Down:
            case Key.S:
                if (ctrlDown)
                {
                    SaveFiles();
                }
                else if (Properties.Settings.Default.ScrollEnabled)
                {
                    GetMainWindow.Scroller.ScrollToVerticalOffset(GetMainWindow.Scroller.VerticalOffset + 30);
                }
                else if (GetPicGallery != null)
                {
                    if (GalleryFunctions.IsOpen)
                    {
                        if (Properties.Settings.Default.PicGallery == 1)
                        {
                            ScrollTo(true, ctrlDown);
                        }
                        else
                        {
                            Pic();
                        }
                    }
                    else
                    {
                        Rotate(true);
                    }
                }
                else
                {
                    Rotate(true);
                }

                return;

            // Zoom
            case Key.Add:
            case Key.OemPlus:
                Zoom(true);
                return;

            case Key.Subtract:
            case Key.OemMinus:
                Zoom(false);
                return;

            default: break;
            }

            #endregion Keys where it can be held down

            #region Key is not held down

            if (!e.IsRepeat)
            {
                switch (e.Key)
                {
                // Esc
                case Key.Escape:
                    if (UserControls_Open())
                    {
                        Close_UserControls();
                        return;
                    }
                    if (Properties.Settings.Default.Fullscreen)
                    {
                        if (Slideshow.SlideTimer != null)
                        {
                            if (Slideshow.SlideTimer.Enabled)
                            {
                                Slideshow.StopSlideshow();
                            }
                        }
                        else
                        {
                            if (GalleryFunctions.IsOpen)
                            {
                                Toggle();
                            }
                            else
                            {
                                Fullscreen_Restore();
                            }
                        }
                        return;
                    }
                    if (GalleryFunctions.IsOpen)
                    {
                        Toggle();
                        return;
                    }
                    if (IsDialogOpen)
                    {
                        IsDialogOpen = false;
                        return;
                    }
                    if (InfoWindow != null)
                    {
                        if (InfoWindow.IsVisible)
                        {
                            InfoWindow.Hide();
                            return;
                        }
                    }
                    if (GetSettingsWindow != null)
                    {
                        if (GetSettingsWindow.IsVisible)
                        {
                            GetSettingsWindow.Hide();
                            return;
                        }
                    }
                    if (Color_Picking.IsRunning)
                    {
                        Color_Picking.StopRunning(false);
                        return;
                    }
                    if (!cm.IsVisible)
                    {
                        SystemCommands.CloseWindow(GetMainWindow);
                    }
                    break;

                // Ctrl + Q
                case Key.Q:
                    if (ctrlDown)
                    {
                        SystemCommands.CloseWindow(GetMainWindow);
                    }

                    break;

                // O, Ctrl + O
                case Key.O:
                    Open();
                    break;

                // X, Ctrl + X
                case Key.X:
                    if (ctrlDown)
                    {
                        Cut(Pics[FolderIndex]);
                    }
                    else
                    {
                        ConfigureSettings.UpdateUIValues.SetScrolling(sender, e);
                    }
                    break;

                // F
                case Key.F:
                    Flip();
                    break;

                // Delete, Shift + Delete
                case Key.Delete:
                    DeleteFile(Pics[FolderIndex], !shiftDown);
                    break;

                // Ctrl + C, Ctrl + Shift + C, Ctrl + Alt + C
                case Key.C:
                    if (ctrlDown)
                    {
                        if (GetResizeAndOptimize != null)
                        {
                            if (GetResizeAndOptimize.IsVisible)
                            {
                                return;     // Prevent paste errors
                            }
                        }

                        if (shiftDown)
                        {
                            System.Threading.Tasks.Task task = Base64.SendToClipboard();
                        }
                        else if (altDown)
                        {
                            CopyBitmap();
                        }
                        else
                        {
                            Copyfile();
                        }
                    }
                    else
                    {
                        CropFunctions.StartCrop();
                    }
                    break;

                // Ctrl + V
                case Key.V:
                    if (ctrlDown)
                    {
                        Paste();
                    }
                    break;

                // Ctrl + I
                case Key.I:
                    if (ctrlDown)
                    {
                        SystemIntegration.NativeMethods.ShowFileProperties(Pics[FolderIndex]);
                    }
                    break;

                // Ctrl + P
                case Key.P:
                    if (ctrlDown)
                    {
                        Print(Pics[FolderIndex]);
                    }
                    break;

                // Ctrl + R
                case Key.R:
                    if (ctrlDown)
                    {
                        Reload();
                    }
                    break;

                // L
                case Key.L:
                    ConfigureSettings.UpdateUIValues.SetLooping(sender, e);
                    break;

                // E
                case Key.E:
                    OpenWith(Pics[FolderIndex]);
                    break;

                // T
                case Key.T:
                    ConfigureSettings.ConfigColors.ChangeBackground(sender, e);
                    break;

                // Space
                case Key.Space:
                    if (GetPicGallery != null)
                    {
                        if (GalleryFunctions.IsOpen)
                        {
                            ScrollTo();
                            return;
                        }
                    }
                    CenterWindowOnScreen();
                    break;

                // 1
                case Key.D1:
                    if (QuickSettingsMenuOpen || GalleryFunctions.IsOpen ||
                        Properties.Settings.Default.Fullscreen)
                    {
                        break;
                    }

                    Tooltip.ShowTooltipMessage(Application.Current.Resources["CenterImageInWindow"]);
                    ConfigureSettings.UpdateUIValues.SetScalingBehaviour(false, false);
                    break;

                // 2
                case Key.D2:
                    if (QuickSettingsMenuOpen || GalleryFunctions.IsOpen ||
                        Properties.Settings.Default.Fullscreen)
                    {
                        break;
                    }

                    Tooltip.ShowTooltipMessage(Application.Current.Resources["CenterImageInWindowFillHeight"]);
                    ConfigureSettings.UpdateUIValues.SetScalingBehaviour(false, true);
                    break;

                // 3
                case Key.D3:
                    if (QuickSettingsMenuOpen || GalleryFunctions.IsOpen ||
                        Properties.Settings.Default.Fullscreen)
                    {
                        break;
                    }

                    Tooltip.ShowTooltipMessage(Application.Current.Resources["CenterApplicationToWindow"]);
                    ConfigureSettings.UpdateUIValues.SetScalingBehaviour(true, false);
                    break;

                // 4
                case Key.D4:
                    if (QuickSettingsMenuOpen || GalleryFunctions.IsOpen ||
                        Properties.Settings.Default.Fullscreen)
                    {
                        break;
                    }

                    Tooltip.ShowTooltipMessage(Application.Current.Resources["CenterApplicationToWindowFillHeight"]);
                    ConfigureSettings.UpdateUIValues.SetScalingBehaviour(true, true);
                    break;

                // F1
                case Key.F1:
                    InfoDialogWindow();
                    break;

                // F2
                case Key.F2:
                    EditTitleBar.EditTitleBar_Text();
                    break;

                // F3
                case Key.F3:
                    Open_In_Explorer();
                    break;

                // F4
                case Key.F4:
                    AllSettingsWindow();
                    break;

                // F5
                case Key.F5:
                    Slideshow.StartSlideshow();
                    break;

                // F6
                case Key.F6:
                    ResetZoom();
                    break;

#if DEBUG
                // F8
                case Key.F8:
                    Unload();
                    break;
#endif
                // F11
                case Key.F11:
                    Fullscreen_Restore();
                    break;

                // Home
                case Key.Home:
                    GetMainWindow.Scroller.ScrollToHome();
                    break;

                // End
                case Key.End:
                    GetMainWindow.Scroller.ScrollToEnd();
                    break;

                default: break;
                }
            }

            #endregion Key is not held down

            #region Alt + keys

            // Alt doesn't work in switch? Waiting for key up is confusing in this case

            if (altDown && !e.IsRepeat)
            {
                // Alt + Z
                if ((e.SystemKey == Key.Z))
                {
                    HideInterfaceLogic.ToggleInterface();
                }

                // Alt + Enter
                else if ((e.SystemKey == Key.Enter))
                {
                    if (Properties.Settings.Default.PicGallery != 2)
                    {
                        Fullscreen_Restore();
                    }
                }
            }

            #endregion Alt + keys
        }
        public override void Execute(object parameter)
        {
            if (!CanExecute(parameter))
            {
                return;
            }

            var popupInfo = PopupInfo as OnClickPopupInfo;

            if (popupInfo == null)
            {
                return;
            }

            InfoWindow win = popupInfo.Container as InfoWindow;

            if (win != null)
            {
                Dispatcher.BeginInvoke(() =>
                {
                    try
                    {
                        FeatureLayer featureLayer = popupInfo.PopupItem.Layer as FeatureLayer;
                        if (featureLayer == null)
                        {
                            return;
                        }

                        FeatureDataForm form = new FeatureDataForm
                        {
                            Width  = win.ActualWidth,
                            Height = win.ActualHeight,
                            Style  = PopupFeatureDataFormStyleHelper.Instance.GetStyle("PopupFeatureDataFormStyle"),
                            CommitButtonContent = Resources.Strings.Apply,
                            GraphicSource       = popupInfo.PopupItem.Graphic,
                            FeatureLayer        = featureLayer,
                            DataContext         = popupInfo,
                        };

                        form.Loaded += (s, e) =>
                        {
                            // enable switching back to the original popup content when the 'Back' button is clicked
                            List <Button> buttons = ControlTreeHelper.FindChildrenOfType <Button>(form, int.MaxValue);
                            if (buttons != null && buttons.Count > 0)
                            {
                                Button backButton = buttons.Where(b => b.Name == "BackButton").FirstOrDefault();
                                if (backButton != null)
                                {
                                    backButton.Content = Resources.Strings.EditValuesCommandEditorBackButtonContent;
                                    backButton.Click  += (ss, ee) => BackToOriginalContent(popupInfo);
                                }
                                Button closeButton = buttons.Where(b => b.Name == "CloseButton").FirstOrDefault();
                                if (closeButton != null)
                                {
                                    closeButton.Click += (ss, ee) => BackToOriginalContent(popupInfo);
                                }
                            }
                            PopupHelper.SetDisplayMode(PopupHelper.DisplayMode.EditValues);
                        };
                        win.Content = null;
                        win.Content = form;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                });
            }
        }
示例#42
0
        private void BtnAddRegion_Click(object sender, RoutedEventArgs e)
        {
            var info = new InfoWindow();

            activationFunction = true;
            MyMap.Children.Remove(polyline);
            MyMap.ClearTextInMap();
            RegionOption.Visibility = Visibility.Hidden;
            DataModel.Localization startLocal = new DataModel.Localization()
            {
                latitude = location.Latitude.ToString(), longitude = location.Longitude.ToString()
            };
            DataModel.Localization endLocal = new DataModel.Localization()
            {
                latitude = polyline.Locations[2].Latitude.ToString(), longitude = polyline.Locations[2].Longitude.ToString()
            };
            Warehouse warehouse = (Warehouse)RegionWarehouse.SelectedItem;
            Employee  empl      = (Employee)RegionEmployee.SelectedItem;
            var       employee  = companyEntities.Employee.FirstOrDefault(e => e.id == empl.id);

            if (region != null)
            {
                if (MyMap.IsAllowRegion(location, polyline.Locations[2], companyEntities, region.id))
                {
                    var start = companyEntities.Localization.First(l => l.id == region.idStartLocalization);
                    var end   = companyEntities.Localization.First(l => l.id == region.idEndLocalization);
                    start.latitude  = startLocal.latitude;
                    start.longitude = startLocal.longitude;
                    end.latitude    = endLocal.latitude;
                    end.longitude   = endLocal.longitude;
                    var reg = companyEntities.Region.Find(region.id);
                    reg.code          = $"{warehouse.code}/{reg.id}";
                    reg.idWarehouse   = warehouse.id;
                    employee.idRegion = reg.id;
                    employee.Region   = reg;
                    companyEntities.SaveChanges();
                    info.ShowInfo("Region edytowano pomyślnie", "Region", "OK");
                }
                else
                {
                    info.ShowInfo("Nowy region nie może pokrywać regionów już istniejących!", "Region", "OK");
                }
            }
            else if (MyMap.IsAllowRegion(location, polyline.Locations[2], companyEntities))
            {
                DataModel.Region newRegion = new DataModel.Region();
                companyEntities.Localization.Add(startLocal);
                companyEntities.Localization.Add(endLocal);
                companyEntities.SaveChanges();
                newRegion.idWarehouse         = warehouse.id;
                newRegion.idStartLocalization = startLocal.id;
                newRegion.idEndLocalization   = endLocal.id;
                companyEntities.Region.Add(newRegion);
                companyEntities.SaveChanges();
                var temp = companyEntities.Region.OrderByDescending(r => r.id).First();
                temp.code         = $"{warehouse.code}/{temp.id}";
                employee.idRegion = temp.id;
                employee.Region   = temp;
                companyEntities.SaveChanges();
                info.ShowInfo("Region zapisano pomyślnie", "Region", "OK");
            }
            else
            {
                info.ShowInfo("Nowy region nie może pokrywać regionów już istniejących!", "Region", "OK");
            }
            region = null;
            BtnShowRegions_Click(sender, e);
        }
示例#43
0
 public void UpdateInfoWindow()
 {
     InfoWindow.UpdateInfoStatic(troop);
 }
        /// <summary>
        /// Retrieves the pop-up info and determines whether there is more than one relationship for the layer. If there is more
        /// than one, the relationships are displayed in a list for the user to choose from before proceeding.
        /// </summary>
        /// <param name="parameter">OnClickPopupInfo from clicked layer</param>
        public void Execute(object parameter)
        {
            relationshipList.Clear();

            OnClickPopupInfo popupInfo = parameter as OnClickPopupInfo;

            popupWindow = popupInfo.Container as InfoWindow;

            // Instantiate the View Model
            if (vm == null)
            {
                vm = new QueryRelatedViewModel(relationshipList, MapApplication.Current.Map);
            }

            // Instantiate the Relationship View
            if (relationshipView == null)
            {
                relationshipView = new RelationshipSelectionView();
            }

            // Instantiate the Keep on Map View
            if (keepOnMapView == null)
            {
                keepOnMapView = new KeepOnMap();
            }

            // Instantiate the No results found View
            if (noRecordsView == null)
            {
                noRecordsView = new NoRecordsFoundView();
            }

            // Set the variables on the ViewModel
            vm.PopupInfo          = popupInfo;
            vm.KeepOnMapView      = keepOnMapView;
            vm.RelationshipView   = relationshipView;
            vm.NoRecordsFoundView = noRecordsView;

            // Set the data context of the RelationshipView and the KeepOnMapView to the QueryRelatedViewModel
            relationshipView.DataContext = vm;
            keepOnMapView.DataContext    = vm;
            noRecordsView.DataContext    = vm;

            // Get the layer info from the pop-up to access the Relationships. Verify the layer is a FeatureLayer to proceed.
            FeatureLayer relatesLayer;
            Layer        lyr = popupInfo.PopupItem.Layer;

            if (lyr is FeatureLayer)
            {
                relatesLayer = lyr as FeatureLayer;

                // Check the number of relationships for the layer
                int relCount = relatesLayer.LayerInfo.Relationships.Count();
                if (relCount > 1) // Layer has more than one relationship
                {
                    foreach (Relationship rel in relatesLayer.LayerInfo.Relationships)
                    {
                        relationshipList.Add(rel);
                    }

                    numberOfRelates = string.Format(Strings.RelationshipsFound,
                                                    relatesLayer.LayerInfo.Relationships.Count().ToString());
                    vm.NumberOfRelationships = numberOfRelates;

                    // Add the available relationships view to the popupWindow.
                    Grid infoWindowGrid = Utils.FindChildOfType <Grid>(popupWindow, 3);
                    infoWindowGrid.Children.Add(relationshipView);


                    // Can now navigate back to attributes and close the popup from the relationship view,
                    // so notify about change in executable state
                    ((DelegateCommand)vm.GoBack).RaiseCanExecuteChanged();
                    ((DelegateCommand)vm.CloseRelationshipView).RaiseCanExecuteChanged();
                }
                else // Layer only has one relationship, so can use Relationship.First to retrieve the ID.
                {
                    // Set the SelectedRelationship property on the ViewModel
                    vm.SelectedRelationship = relatesLayer.LayerInfo.Relationships.First();
                    // Call Execute method on the ViewModel
                    vm.QueryRelated.Execute(vm.SelectedRelationship);
                }
            }
            else
            {
                return;
            }
        }
示例#45
0
 private void miDataBaseEditor_Click(object sender, RoutedEventArgs e)
 {
     if (CurrentBase.BaseIsLoaded())
     {
         miMain.Header = "Закрыть";
         contentControl.Content = new StorageEditor.StorageEditorForm();
     }
     else
     {
         var infoWindow = new InfoWindow
         {
             Message = { Text = "База данных не загружена" }
         };
         DialogHost.Show(infoWindow, "MandarinHost");
     }
 }
示例#46
0
        /// <summary>
        /// 标注点击时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMarkerClick(object sender, BaiduMap.MarkerClickEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(e.P0.Title))
                {
                    var pin = Map.Pins.Find(e.P0);
                    if (pin?.Terminal != null)
                    {
                        var color = pin?.Terminal?.RankColor ?? "#4a89dc";

                        //cardView
                        var cardView = new CardView(Context)
                        {
                            Radius = 15
                        };
                        cardView.SetCardBackgroundColor(Color.FromHex(color).ToAndroid());

                        //布局
                        var layout = new LinearLayout(Context)
                        {
                            Orientation = Orientation.Vertical
                        };
                        layout.SetPadding(10, 10, 10, 10);

                        //Title
                        var tview = new TextView(Context);
                        tview.SetPadding(10, 10, 10, 10);
                        tview.SetTextColor(Color.White.ToAndroid());
                        tview.TextSize = 12;
                        tview.Text     = e.P0.Title;

                        //Button
                        var param = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent)
                        {
                            Height = 45
                        };
                        var button = new Android.Widget.Button(Context);
                        button.Text             = "去拜访";
                        button.TextSize         = 10;
                        button.LayoutParameters = param;
                        button.SetBackgroundResource(Resource.Drawable.roundShape);
                        button.SetTextColor(Color.White.ToAndroid());
                        button.Click += (sender, ar) =>
                        {
                            var pin = Map.Pins.Find(e.P0);
                            pin?.SendClicked(pin?.Terminal);
                        };

                        layout.AddView(tview);
                        layout.AddView(button);

                        cardView.AddView(layout);

                        var window = new InfoWindow(cardView, e.P0.Position, -e.P0.Icon.Bitmap.Height);
                        NativeMap.Map.ShowInfoWindow(window);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
示例#47
0
        private async void AddClasses()
        {
            try
            {
                int timeIndex = -1;

                StudentsClass sClass;
                sClass = (StudentsClass)ClasseslistBox.SelectedItem;
                ClassRoom classRoom;
                if (UpperWeekradioButton.IsChecked == true && TimecomboBox.SelectedIndex !=-1 && DaycomboBox.SelectedIndex != -1)
                {
                    timeIndex = 0;
                    timeIndex += DaycomboBox.SelectedIndex * 6;
                    timeIndex += TimecomboBox.SelectedIndex;
                }
                if (LowerWeekradioButton.IsChecked == true && TimecomboBox.SelectedIndex != -1 && DaycomboBox.SelectedIndex != -1)
                {
                    timeIndex = 0;
                    timeIndex += 36;
                    timeIndex += DaycomboBox.SelectedIndex * 6;
                    timeIndex += TimecomboBox.SelectedIndex;
                }
                classRoom = (ClassRoom)ClassRoomlistView.Items[0];
                bool freeClassroom = true, existAddClassInLVIP = false;
                foreach (var item in settings)
                {
                    //Проверка не занята ли аудитория в это время
                    if (item.Room == classRoom && item.Time == timeIndex)
                    { freeClassroom = false; break; }
                }
                if (sClass != null && classRoom != null && timeIndex != -1)
                {
                    if (freeClassroom)
                    {
                        foreach (var item in settings)
                        {

                            if (item.sClass == sClass)
                            {
                                item.Room = classRoom;
                                item.Time = timeIndex;
                                existAddClassInLVIP = true;
                                var infoWindow = new InfoWindow
                                {
                                    Message = { Text = "Пара зафиксирована" }
                                };

                                await DialogHost.Show(infoWindow, "VIPHost");
                            }

                        }
                        if (!existAddClassInLVIP)
                        {
                            FixedClasses vi = new FixedClasses(sClass, timeIndex, classRoom);
                            settings.Add(vi);
                            var infoWindow = new InfoWindow
                            {
                                Message = { Text = "Пара зафиксирована" }
                            };

                            await DialogHost.Show(infoWindow, "VIPHost");
                        }
                    }
                    else
                    {
                        var infoWindow = new InfoWindow
                        {
                            Message = { Text = "В это время в этой аудитории уже стоит пара" }
                        };

                        await DialogHost.Show(infoWindow, "VIPHost");
                    }
                }
            }
            catch
            {

            }
        }
示例#48
0
        private async void miDBOpen_Click(object sender, RoutedEventArgs e)
        {
            //здесь сделать окно для открытия
            OpenFileDialog openFile = new OpenFileDialog();
            openFile.Filter = "DB files (*.mandarin)|*.mandarin";
            if (openFile.ShowDialog() == false)
            {
                return;
            }
            try
            {
                Base openedBase = CurrentBase.LoadBase(openFile.FileName);
                FactorsLoader.UpdateAssemblyPath(openedBase.Factors);
                if (await CheckLostFactors(openedBase.Factors))
                {
                    CheckNewFactors(openedBase.Factors);
                    CurrentBase.OpenBase(openedBase);
                    LoadDataBaseInfo();
                    LoadSchedules();
                    LoadFactorsWithUserData();
                    miDBSettings.IsEnabled = true;
                    miDBSave.IsEnabled = true;
                    miDBSaveAs.IsEnabled = true;
                    miCore.IsEnabled = true;
                    miDataBaseEditor.IsEnabled = true;
                }
            }
            catch (Exception ex)
            {
                var infoWindow = new InfoWindow
                {
                    Message = { Text = "Ошибка открытия файла базы" }
                };
                await DialogHost.Show(infoWindow, "MandarinHost");
                return;
            }

        }
        /// <summary>
        /// Performs the relationship query.
        /// </summary>
        /// <remarks>Called from the doQuery method.</remarks>
        private void QueryRelationship()
        {
            // Set the popupWindow and subscribe to changes on the popupWindow.IsOpen property
            popupWindow = PopupInfo.Container as InfoWindow;

            // Set the attribute grid container and subscripbe to changes on the Visibility property
            attributeGridContainer = MapApplication.Current.FindObjectInLayout(CONTAINER_NAME) as FrameworkElement;
            ExtensionMethods.Properties.NotifyOnDependencyPropertyChanged("Visibility", attributeGridContainer, OnDataGridVisibilityChanged);

            // Listen for selection of a different layer in the map contents.
            MapApplication.Current.SelectedLayerChanged += Current_SelectedLayerChanged;

            // Listen for a change in the selected index of the PopupInfo (indicating the popup item has changed).
            PopupInfo.PropertyChanged += PopupInfo_PropertyChanged;

            // Locate the grid inside the popup window and remove the RelationshipView. This was initially inserted if
            // multiple relationships for a feature were detected.
            Grid infoWindowGrid = Utils.FindChildOfType <Grid>(popupWindow, 3);

            infoWindowGrid.Children.Remove(RelationshipView);

            // Set the relationshipID for the QueryTask.
            int relationshipID = SelectedRelationship.Id;

            // Get the feature and layer info from the pop-up. The PopupItem property of OnClickPopupInfo
            // provides information about the item currently shown in the pop-up.
            Graphic inputFeature = PopupInfo.PopupItem.Graphic;

            relatesLayer = PopupInfo.PopupItem.Layer as FeatureLayer; // The layer to get related records for. This is used to get the RelationshipID and Query url.

            // Get the name of the ObjectID field.
            objectIDField = relatesLayer.LayerInfo.ObjectIdField;

            // Input parameters for QueryTask
            RelationshipParameter relationshipParameters = new RelationshipParameter()
            {
                ObjectIds           = new int[] { (int)inputFeature.Attributes[objectIDField] },
                OutFields           = new string[] { "*" }, // Return all fields
                ReturnGeometry      = true,                 // Return the geometry so that features can be displayed on the map if applicable
                RelationshipId      = relationshipID,       // Obtain the desired RelationshipID from the Service Details page. Here it takes the first relationship it finds if there is more than one.
                OutSpatialReference = map.SpatialReference
            };

            // Specify the Feature Service url for the QueryTask.
            queryTask.Url      = relatesLayer.Url;
            queryTask.ProxyURL = relatesLayer.ProxyUrl;

            // Events for the successful completion of the RelationshipQuery and for if the Query fails
            queryTask.ExecuteRelationshipQueryCompleted += QueryTask_ExecuteRelationshipQueryCompleted;
            queryTask.Failed += QueryTask_Failed;

            // Execute the Query Task with specified parameters
            queryTask.ExecuteRelationshipQueryAsync(relationshipParameters);

            // Create the BusyIndicator and insert into the grid of the popup window.
            indicator             = new BusyIndicator();
            indicator.BusyContent = Strings.RetrievingRecords;
            if (infoWindowGrid != null)
            {
                infoWindowGrid.Children.Add(indicator);
                indicator.IsBusy = true;
            }
        }
示例#50
0
        private async void SetManualPushpinsAsync()
        {
            Lock = true;
            InfoWindow info     = new InfoWindow();
            string     sender   = "Nadawca";
            string     receiver = "Odbiorca";

            if (From != null)
            {
                info.ShowInfo("Czy chcesz zmienić lokalizacje nadawcy?", "Zmiana lokalizacji", "Nie", "Tak");
                if (info.Answer)
                {
                    info.ShowInfo("Dodaj lokalizację nadawcy poprzez dwukrotne kliknięcie na mapie!", "Dodaj pinezkę", "Ok");
                    await ParcelMap.PinPushpinWhenClicked(true, sender);
                }
            }
            else
            {
                info.ShowInfo("Dodaj lokalizację nadawcy poprzez dwukrotne kliknięcie na mapie!", "Dodaj pinezkę", "Ok");
                await ParcelMap.PinPushpinWhenClicked(false, sender);
            }

            if (To != null)
            {
                info.ShowInfo("Czy chcesz zmienić lokalizacje odbiorcy?", "Zmiana lokalizacji", "Nie", "Tak");
                if (info.Answer)
                {
                    info.ShowInfo("Dodaj lokalizację odbiorcy poprzez dwukrotne kliknięcie na mapie!", "Dodaj pinezkę", "Ok");
                    await ParcelMap.PinPushpinWhenClicked(true, receiver);
                }
            }
            else
            {
                info.ShowInfo("Dodaj lokalizację odbiorcy poprzez dwukrotne kliknięcie na mapie!", "Dodaj pinezkę", "Ok");
                await ParcelMap.PinPushpinWhenClicked(false, receiver);
            }

            var pushpins = ParcelMap.GetPushpins();

            From = pushpins.FirstOrDefault(p => p.Content.Equals(sender)).Location;
            To   = pushpins.FirstOrDefault(p => p.Content.Equals(receiver)).Location;

            if (From == null || To == null)
            {
                info.ShowInfo("Ze względu na brak jednej z lokalizacji nie można wyznaczyć trasy.\nProszę powtórz procedurę dodawania pinezek.", "Błąd wyznaczania trasy", "Ok");
                info.Close();
                Lock = false;
                return;
            }
            string uri = $"http://dev.virtualearth.net/REST/V1/Routes/Driving?wp.0={From.Latitude},{From.Longitude}&wp.1={To.Latitude},{To.Longitude}&rpo=Points&key={MAP_KEY}";

            var response = DriveRoute(uri);

            if (response != null)
            {
                Route(response);
                SetDistanceAndDuration();
            }
            else
            {
                info.ShowInfo("Nie można wyznaczyć trasy. Proszę spróbować jeszcze raz.", "Błąd wyznaczania trasy", "Ok");
            }

            info.Close();
            Lock = false;
        }
示例#51
0
 private async void LoadFacultyAndGroups()
 {
     if (facultiesAndGroups.GroupsWithoutFacultyExists())
     {
         var infoWindow = new InfoWindow
         {
             Message = { Text = "Внимание есть группы не относящееся ни к 1 факультету.\n" +
                                 "Зайдите в настройки чтобы отнести группы к факультету!" }
         };
         await DialogHost.Show(infoWindow, "MandarinHost");
     }
 }
示例#52
0
        private bool CalculateCost()
        {
            var        parcelAddViewModel = (ParcelAddViewModel)DataContext;
            InfoWindow info = new InfoWindow();

            if (Lock || parcelAddViewModel.ParcelDistance == 0)
            {
                if (_noOfErrorsOnScreen == 0)
                {
                    info.ShowInfo("Nie można obliczyć kosztu dopóki nie zostanie wyznaczona trasa.\nCzy wyznaczyć trasę automatycznie" +
                                  " na podstawie adresów?", "Błąd wyliczenia kosztów", "Nie", "Tak");
                }
                else
                {
                    info.ShowInfo("Nie można obliczyć kosztu dopóki nie zostanie wyznaczona trasa." +
                                  "\nNie można wyznaczyć trasy dopóki nie zostaną wprowadzone wymagane dane", "Błąd wyliczenia kosztów", "Ok");
                    info.Close();
                    return(false);
                }
                if (info.Answer)
                {
                    SetPushpins();
                }
                else
                {
                    info.Close();
                    return(false);
                }
            }
            double dimensions = double.Parse(parcelAddViewModel.ParcelHeight) + double.Parse(parcelAddViewModel.ParcelLength) + double.Parse(parcelAddViewModel.ParcelWidth);

            dimensions *= 0.1;
            double distance = parcelAddViewModel.ParcelDistance * 0.01;
            double weight   = double.Parse(parcelAddViewModel.ParcelWeight) * 0.1;
            double worth    = double.Parse(parcelAddViewModel.ParcelWorth) * 0.001;

            int result = (int)(dimensions + distance + weight + worth);

            switch (parcelAddViewModel.ParcelTypeSelected.id)
            {
            case (int)EnumTypeOfParcel.StandardParcel:
                break;

            case (int)EnumTypeOfParcel.UnstandardParcel:
                result += (int)(result * 0.1);
                break;
            }

            var myTariff = companyEntities.Tariff.FirstOrDefault(t => result >= t.valueFrom && result <= t.valueTo);

            if (myTariff == null)
            {
                info.ShowInfo("Nie można obliczyć kosztu!", "Błąd wyliczenia kosztów", "Ok");
                info.Close();
                return(false);
            }
            parcelAddViewModel.MyTariff = myTariff;
            if (parcelAddViewModel.ParcelTypeSelected.id == (int)EnumTypeOfParcel.CashOnDelivery)
            {
                Worth.Text = (myTariff.cost + 10).ToString();
            }
            else
            {
                Worth.Text = myTariff.cost.ToString();
            }
            return(true);
        }
示例#53
0
        private async void CreateExcelDocument()
        {
            if (schedule.RemoveClases.Count == 0)
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter = "Excel (*.xlsx|*.xlsx";
                saveFileDialog.FilterIndex = 2;
                saveFileDialog.RestoreDirectory = true;
                if (saveFileDialog.ShowDialog() == true)//сделать формирование в отдельном потоке
                {
                    filepath = saveFileDialog.FileName;
                    thread = new Thread(new ThreadStart(SaveExcel));
                    thread.Start();
                    var infoWindow = new InfoWindow
                    {
                        Message = { Text = "Расписание будет сформировано:\n" + filepath + "\nПожалуйста подождите" }
                    };
                    await DialogHost.Show(infoWindow, "MandarinHost");
                    


                }
            }
            else
            {
                var infoWindow = new InfoWindow
                {
                    Message = { Text = "Nope" }
                };

                await DialogHost.Show(infoWindow, "MandarinHost");
            }
        }
示例#54
0
 private void Clear_DEBUG_window(object sender, EventArgs e)
 {
     InfoWindow.Clear();
 }
示例#55
0
        private async void CheckRemoveClasses(System.ComponentModel.CancelEventArgs e)
        {
            if (schedule.RemoveClases.Count != 0)
            {
                var infoWindow = new InfoWindow
                {
                    Message = { Text = "Остались непоставленные пары" }
                };

                await DialogHost.Show(infoWindow, "MandarinHost");
                e.Cancel = true;
            }
        }
示例#56
0
        //****************************************************************
        // Run commands to control a PWM channel
        //
        // Notes
        // * Will only affect "bit 0" of PWM config register. Other 31 bits should be undisturbed.

        private void Execute_PWM_cmd(object sender, EventArgs e)
        {
            string command_str;

            int    channel_base_address, on_time_nS, on_time_FPGA_count, data, period_time_FPGA_count;
            int    PWM_status;
            double period_time_nS;

            FPGA_uP_IO.ErrorCode status;

            status = FPGA_uP_IO.ErrorCode.NO_ERROR;
            int config_value = 0;

            // get values from PWM form and make checks

            int    PWM_channel   = (int)numericUpDown5.Value;
            double PWM_frequency = double.Parse(textBox3.Text);

            if ((PWM_frequency < MIN_PWM_FREQUENCY) || (PWM_frequency > MAX_PWM_FREQUENCY))
            {
                MessageBox.Show("Input PWM frequenct in range 0.01 to 100 (kHz)");
                return;
            }
            int PWM_width_percent = Convert.ToInt32(numericUpDown6.Value);

            // Calculate FPGA/uP command parameters

            channel_base_address   = (Int32)(FPGA_uP_IO.PWM_base + (PWM_channel * FPGA_uP_IO.REGISTERS_PER_PWM_CHANNEL));
            period_time_nS         = Convert.ToInt32(1000000.0 / PWM_frequency);
            period_time_FPGA_count = (int)(period_time_nS / 20);
            on_time_nS             = Convert.ToInt32((PWM_width_percent * period_time_nS) / 100);
            on_time_FPGA_count     = on_time_nS / 20;

            // check mode to execute

            if (radioButton5.Checked == true)       // full configuration
            {
                command_str = build_command('w', DEFAULT_PORT,
                                            (channel_base_address + (int)FPGA_Sys.PWM_REG.PERIOD), period_time_FPGA_count);
                InfoWindow.AppendText("command = " + command_str + Environment.NewLine);
                status = (do_command(command_str, out data));
                InfoWindow.AppendText("Return code = " + status + Environment.NewLine);

                command_str = build_command('w', DEFAULT_PORT,
                                            (channel_base_address + (int)FPGA_Sys.PWM_REG.ON_TIME), on_time_FPGA_count);
                InfoWindow.AppendText("command = " + command_str + Environment.NewLine);
                status = (do_command(command_str, out data));
                InfoWindow.AppendText("Return code = " + status + Environment.NewLine);
            }

            if (radioButton6.Checked == true)      // set PWM ON time
            {
                command_str = build_command('w', DEFAULT_PORT,
                                            (channel_base_address + (int)FPGA_Sys.PWM_REG.ON_TIME), on_time_FPGA_count);
                InfoWindow.AppendText("command = " + command_str + Environment.NewLine);
                status = (do_command(command_str, out data));
                InfoWindow.AppendText("Return code = " + status + Environment.NewLine);
            }

            if ((radioButton7.Checked == true) | (checkBox2.Checked == true))      // enable PWM channel
            {
                config_value = 1;
            }

            if (radioButton8.Checked == true)      // disable PWM channel
            {
                config_value = 0;
            }

            // Process configuration data. Ensure that only bit-1 is changed.

            command_str = build_command('r', DEFAULT_PORT,
                                        (channel_base_address + (int)FPGA_Sys.PWM_REG.CONFIG), config_value);
            InfoWindow.AppendText("command = " + command_str + Environment.NewLine);
            status = (do_command(command_str, out PWM_status));
            InfoWindow.AppendText("Return code = " + status + Environment.NewLine);

            config_value = ((int)(PWM_status & 0xFFFF0000) | (int)(config_value));

            if (radioButton4.Checked == true)    // override to clear config register
            {
                config_value = 0;
            }

            command_str = build_command('w', DEFAULT_PORT,
                                        (channel_base_address + (int)FPGA_Sys.PWM_REG.CONFIG), config_value);
            InfoWindow.AppendText("command = " + command_str + Environment.NewLine);
            status = (do_command(command_str, out data));
            InfoWindow.AppendText("Return code = " + status + Environment.NewLine);
        }
 async void LoadToExcel()
 {
     int countCheck = Convert.ToInt32(lblCount.Content.ToString());
     checkedsubgroups = new StudentSubGroup[countCheck];
     int indexChecked = 0;
     for (int indexCheckBox = 0; indexCheckBox < chSubGroups.Count(); indexCheckBox++)
     {
         if (chSubGroups[indexCheckBox].IsChecked == true)
         {
             checkedsubgroups[indexChecked] = schedule.EStorage.StudentSubGroups[indexCheckBox];
             indexChecked++;
         }
     }
     SaveFileDialog saveFileDialog = new SaveFileDialog();
     saveFileDialog.Filter = "Excel (*.xlsx|*.xlsx";
     saveFileDialog.FilterIndex = 2;
     saveFileDialog.RestoreDirectory = true;
     if (saveFileDialog.ShowDialog() == true)//сделать формирование в отдельном потоке
     {
         var infoWindow = new InfoWindow
         {
             Message = { Text = "Расписание будет сформировано:\n" + filepath + "\nНажмите ОК и ожидайте" }
         };
         await DialogHost.Show(infoWindow, "ScheduleSubGroupsForExcel");
         filepath = saveFileDialog.FileName;
         thread = new Thread(new ThreadStart(SaveExcel));
         thread.Start();                
         btnSave.IsEnabled = false;
     }
 }
示例#58
0
        //****************************************************************
        // Set the H-bridge configuration register
        private void Set_H_bridge_config_Click(object sender, EventArgs e)
        {
            int config_value, PWM_config, data, command;

            FPGA_uP_IO.ErrorCode status;

            config_value = 0;
            int PWM_channel          = (int)numericUpDown5.Value;
            int channel_base_address = (int)(FPGA_uP_IO.PWM_base + (PWM_channel * FPGA_uP_IO.REGISTERS_PER_PWM_CHANNEL));
            int motor_cmd            = (int)comboBox3.SelectedIndex;

            // get current value of PWM configuration

            string command_str = build_command('r', DEFAULT_PORT,
                                               (channel_base_address + (int)FPGA_Sys.PWM_REG.CONFIG), 0);

            InfoWindow.AppendText("command = " + command_str + Environment.NewLine);
            status = (do_command(command_str, out PWM_config));

            // create new configuration value

            if (checkBox3.Checked == true)
            {
                config_value = ((int)(config_value & (~FPGA_Sys.INT_H_BRIDGE_MASK)) | (int)FPGA_Sys.INT_H_BRIDGE.ENABLE);
            }
            else
            {
                config_value = (int)(config_value & (~FPGA_Sys.INT_H_BRIDGE_MASK));
            }

            if (checkBox4.Checked == true)
            {
                config_value = ((int)(config_value & (~FPGA_Sys.EXT_H_BRIDGE_MASK)) | (int)FPGA_Sys.EXT_H_BRIDGE.ENABLE);
            }
            else
            {
                config_value = (int)(config_value & (~FPGA_Sys.EXT_H_BRIDGE_MASK));
            }

            if (radioButton14.Checked == true)     // PWM/PWM H-bridge mode
            {
                config_value = ((int)(config_value & (~FPGA_Sys.H_BRIDGE_MODE_MASK)) | (int)FPGA_Sys.H_BRIDGE_MODE.PWM_CONTROL);
            }
            else
            {
                config_value = (int)(config_value & (~FPGA_Sys.H_BRIDGE_MODE_MASK));
            }

            if (radioButton3.Checked == true)      //  PWM/DIR H-bridge mode
            {
                config_value = ((int)(config_value & (~FPGA_Sys.H_BRIDGE_MODE_MASK)) | (int)FPGA_Sys.H_BRIDGE_MODE.DIR_CONTROL);
            }
            else
            {
                config_value = (int)(config_value & (~FPGA_Sys.H_BRIDGE_MODE_MASK));
            }
            if (radioButton16.Checked == true)     // COAST during PWM dwell time
            {
                config_value = ((int)(config_value & (~FPGA_Sys.PWM_DWELL_MODE_MASK)) | (int)FPGA_Sys.PWM_DWELL_MODE.COAST);
            }
            else                                   // BRAKE during PWM dwell time
            {
                config_value = (int)(config_value & (~FPGA_Sys.PWM_DWELL_MODE_MASK));
            }
            command = 0;
            Boolean change_cmd = false;

            switch (motor_cmd)
            {
            case 0:       // no change
                break;

            case 1:      // COAST
                change_cmd = true;
                command    = (int)FPGA_Sys.MOTOR_CMDS.COAST;
                break;

            case 2:       // FORWARD
                change_cmd = true;
                command    = (int)FPGA_Sys.MOTOR_CMDS.FORWARD;
                break;

            case 3:       // BACKWARD
                change_cmd = true;
                command    = (int)FPGA_Sys.MOTOR_CMDS.BACKWARD;
                break;

            case 4:       // BRAKE
                change_cmd = true;
                command    = (int)FPGA_Sys.MOTOR_CMDS.BRAKE;
                break;

            default:
                break;
            }
            if (change_cmd == true)
            {
                config_value = ((int)(config_value & (~FPGA_Sys.MOTOR_CMDS_MASK)) | command);
            }
            config_value = (int)(config_value & 0xFFFF0000) | (PWM_config & 0x0000FFFF);

            // Output PWM configuaration value to PWM

            command_str = build_command('w', DEFAULT_PORT,
                                        (channel_base_address + (int)FPGA_Sys.PWM_REG.CONFIG), config_value);
            InfoWindow.AppendText("command = " + command_str + Environment.NewLine);
            status = (do_command(command_str, out data));
            InfoWindow.AppendText("Return code = " + status + Environment.NewLine);
        }
示例#59
0
        //****************************************************************
        // Update H-bridge command only
        private void Update_H_bridge_cmd_click(object sender, EventArgs e)
        {
            FPGA_uP_IO.ErrorCode status;
            int data, PWM_config;

            int config_value         = 0;
            int PWM_channel          = (int)numericUpDown5.Value;
            int channel_base_address = (int)(FPGA_uP_IO.PWM_base + (PWM_channel * FPGA_uP_IO.REGISTERS_PER_PWM_CHANNEL));
            int motor_cmd            = (int)comboBox3.SelectedIndex;

            // get current value of PWM configuration

            string command_str = build_command('r', DEFAULT_PORT,
                                               (channel_base_address + (int)FPGA_Sys.PWM_REG.CONFIG), 0);

            // InfoWindow.AppendText("command = " + command_str + Environment.NewLine);
            status = (do_command(command_str, out PWM_config));

            int     command    = 0;
            Boolean change_cmd = false;

            switch (motor_cmd)
            {
            case 0:       // no change
                break;

            case 1:      // COAST
                change_cmd = true;
                command    = (int)FPGA_Sys.MOTOR_CMDS.COAST;
                break;

            case 2:       // FORWARD
                change_cmd = true;
                command    = (int)FPGA_Sys.MOTOR_CMDS.FORWARD;
                break;

            case 3:       // BACKWARD
                change_cmd = true;
                command    = (int)FPGA_Sys.MOTOR_CMDS.BACKWARD;
                break;

            case 4:       // BRAKE
                change_cmd = true;
                command    = (int)FPGA_Sys.MOTOR_CMDS.BRAKE;
                break;

            default:
                break;
            }
            if (change_cmd == true)
            {
                config_value = ((int)(config_value & (~FPGA_Sys.MOTOR_CMDS_MASK)) | command);
            }
            config_value = (int)(config_value & 0xFFFF0000) | (PWM_config & 0x0000FFFF);

            // Output PWM configuaration value to PWM

            command_str = build_command('w', DEFAULT_PORT,
                                        (channel_base_address + (int)FPGA_Sys.PWM_REG.CONFIG), config_value);
            InfoWindow.AppendText("command = " + command_str + Environment.NewLine);
            status = (do_command(command_str, out data));
            InfoWindow.AppendText("Return code = " + status + Environment.NewLine);
        }
        /// <summary>
        /// Check Method cached user in Redis or not (modal).
        /// If the user is not cached in Redis then its cache.
        /// Called from the method ConnectToServer (modal).
        /// </summary>
        /// <param name="context">The context of the interaction with the database.</param>
        /// <param name="userId">User ID.</param>
        /// <param name="services">Services class object to check - whether our services work.</param>
        /// <param name="logging">Logging class object to create the log.</param>
        /// <param name="frm">Instance a modal window.</param>
        private static void RedisOrSQLStorage5(Storage5Context context, int userId, Services services, Logging logging, InfoWindow frm)
        {
            IDatabase db = null;
            if (services.RedisIsStarted)
            {
                using (var redisClient = ConnectionMultiplexer.Connect("localhost"))
                {
                    db = redisClient.GetDatabase();
                    string value = db.StringGet($"user:{userId}");

                    if (string.IsNullOrEmpty(value))
                    {
                        var queryUserStorage = context.User.Where(x => x.Id == userId);
                        GetDataFromSQL(queryUserStorage, db, true, logging, frm);
                    }
                    else
                    {
                        GetDataFromRedis(value, frm);
                    }
                }
            }
            else
            {
                var queryUserStorage = context.User.Where(x => x.Id == userId);
                GetDataFromSQL(queryUserStorage, db, false, logging, frm);
            }
        }