상속: MonoBehaviour
        /// <summary>
        /// DBに存在するかチェック
        /// </summary>
        public override DataRow[] GetExistsDataRow( string directoryName ,
                                                    Text.TextData textData ,
                                                    Translate.TranslateText translateText )
        {
            Text.TextDataScienceDefs tData = (Text.TextDataScienceDefs)textData;
            Translate.TranslateTextScienceDefs tText = ( Translate.TranslateTextScienceDefs ) translateText;

            var where = new System.Text.StringBuilder();
            where.Clear();

            if ( directoryName != null )
            {
                where.Append( String.Format( "{0}='{1}'" ,
                                             ColumnNameDirName ,
                                             this.DoubleSiglQrt( directoryName ) ) );
                where.Append( " AND " );
            }

            where.Append( String.Format( "{0}='{1}'" ,
                                         ColumnNameID ,
                                         this.DoubleSiglQrt( tData.ID ) ) );

            where.Append( " AND " );
            where.Append( String.Format( "{0}='{1}'" ,
                                         ColumnNameResultText ,
                                         this.DoubleSiglQrt( tText.Result.ResultText ) ) );

            where.Append( " AND " );
            where.Append( String.Format( "{0}='{1}'" ,
                                         ColumnNameResultIndex ,
                                         tText.Result.ResultIndex.ToString() ) );

            return this.Select( where.ToString() );
        }
예제 #2
0
 public void TestMethod1()
 {
     var method = new Translate() {
         To = "en",
         Text = "建议开发者使用如下方法进行修复"
     };
     var result = ApiClient.ExecuteWrap(method).Result;
 }
        /// <summary>
        /// タイトル等データをセット
        /// </summary>
        public override void SetTitleData( DataRow row ,
                                      Text.TextData textData ,
                                      Translate.TranslateText translateText )
        {
            Text.TextDataDepartments tData = ( Text.TextDataDepartments ) textData;

            if ( row.RowState == DataRowState.Added || row.RowState == DataRowState.Detached )
            {
                // パーツ名
                this.SetDataValue( row , ColumnNameName , tData.Name );
            }
        }
        /// <summary>
        /// タイトル等データをセット
        /// </summary>
        public override void SetTitleData( DataRow row ,
                                      Text.TextData textData ,
                                      Translate.TranslateText translateText )
        {
            Text.TextDataTechTree tData = (Text.TextDataTechTree)textData;

            if ( row.RowState == DataRowState.Added || row.RowState == DataRowState.Detached )
            {
                // ID
                this.SetDataValue( row , ColumnNameID , tData.ID );
            }

            // タイトル
            this.SetDataValue( row , ColumnNameTitle , tData.Title );
        }
        /// <summary>
        /// DBに存在するかチェック
        /// </summary>
        public override DataRow[] GetExistsDataRow( string directoryName ,
                                                    Text.TextData textData ,
                                                    Translate.TranslateText translateText )
        {
            Text.TextDataDepartments tData = ( Text.TextDataDepartments ) textData;

            var where = new System.Text.StringBuilder();
            where.Clear();

            if ( directoryName != null )
            {
                where.Append( String.Format( "{0}='{1}'" ,
                                         ColumnNameDirName ,
                                         this.DoubleSiglQrt( directoryName ) ) );
                where.Append( " AND " );
            }

            where.Append( String.Format( "{0}='{1}'" ,
                                         ColumnNameName ,
                                         this.DoubleSiglQrt( tData.Name ) ) );

            return this.Select( where.ToString() );
        }
        protected override void DoRender(HtmlTextWriter output)
        {
            ArrayList         selected;
            OrderedDictionary unselected;

            GetSelectedItems(GetItems(Sitecore.Context.ContentDatabase.GetItem(ItemID)), out selected, out unselected);
            StringBuilder stringBuilder = new StringBuilder();

            foreach (DictionaryEntry dictionaryEntry in unselected)
            {
                Item obj = dictionaryEntry.Value as Item;
                if (obj != null)
                {
                    stringBuilder.Append(obj.DisplayName + ",");
                    stringBuilder.Append(GetItemValue(obj) + ",");
                }
            }
            RenderStartLocationInput(output);
            output.Write("<input type='hidden' width='100%' id='multilistValues" + (object)ClientID + "' value='" + stringBuilder + "' style='width: 200px;margin-left:3px;'>");
            ServerProperties["ID"] = ID;
            string str1 = string.Empty;

            if (ReadOnly)
            {
                str1 = " disabled='disabled'";
            }
            output.Write("<input id='" + ID + "_Value' type='hidden' value='" + StringUtil.EscapeQuote(Value) + "' />");
            output.Write("<table" + GetControlAttributes() + ">");
            output.Write("<tr>");
            output.Write("<td class='scContentControlMultilistCaption' width='50%' colspan='4'>" + Translate.Text("All") + "</td>");
            output.Write("</tr>");
            output.Write("<tr>");
            output.Write("<td valign='top' height='100%' colspan='4'>");
            output.Write("<div style='width:200%;overflow:hidden;height:30px'><input type='text' width='100%' class='scIgnoreModified bucketSearch inactive' value='" + TypeHereToSearch + "' id='filterBox" + ClientID + "' " + (Sitecore.Context.ContentDatabase.GetItem(ItemID).Access.CanWrite() ? string.Empty : "disabled") + ">");
            output.Write("<span id='prev" + ClientID + "' class='hovertext' style='cursor:pointer;' onMouseOver=\"this.style.color='#666'\" onMouseOut=\"this.style.color='#000'\"> <img width='10' height='10' src='/sitecore/shell/Applications/Buckets/images/right.png' style='margin-top: 1px;'> " + Translate.Text("prev") + " |</span>");
            output.Write("<span id='next" + ClientID + "' class='hovertext' style='cursor:pointer;' onMouseOver=\"this.style.color='#666'\" onMouseOut=\"this.style.color='#000'\"> " + Translate.Text("next") + " <img width='10' height='10' src='/sitecore/shell/Applications/Buckets/images/left.png' style='margin-top: 1px;'>  </span>");
            output.Write("<span id='refresh" + ClientID + "' class='hovertext' style='cursor:pointer;' onMouseOver=\"this.style.color='#666'\" onMouseOut=\"this.style.color='#000'\"> " + Translate.Text("refresh") + " <img width='10' height='10' src='/sitecore/shell/Applications/Buckets/images/refresh.png' style='margin-top: 1px;'>  </span>");
            output.Write("<span id='goto" + ClientID + "' class='hovertext' style='cursor:pointer;' onMouseOver=\"this.style.color='#666'\" onMouseOut=\"this.style.color='#000'\"> " + Translate.Text("go to item") + " <img width='10' height='10' src='/sitecore/shell/Applications/Buckets/images/text.png' style='margin-top: 1px;'>  </span>");
            output.Write("<span style='padding-left:34px;'><strong>" + Translate.Text("Page Number") + ": </strong></span><span id='pageNumber" + ClientID + "'></span></div>");
            string str2 = !UIUtil.IsIE() || UIUtil.GetBrowserMajorVersion() != 9 ? "10" : "11";

            output.Write("<select id=\"" + ID + "_unselected\" class=\"scContentControlMultilistBox\" size=\"" + str2 + "\"" + str1 + " >");
            foreach (DictionaryEntry dictionaryEntry in unselected)
            {
                Item obj = dictionaryEntry.Value as Item;
                if (obj != null)
                {
                    string str3 = OutputString(obj);
                    output.Write("<option value='" + GetItemValue(obj) + "'>" + str3 + "</option>");
                }
            }
            output.Write("</select>");
            output.Write("</td>");
            output.Write("</tr>");
            output.Write("<tr>");
            output.Write("<td class='scContentControlMultilistCaption' width='100%'>Selected</td>");
            output.Write("</tr>");
            output.Write("<tr>");
            output.Write("<td valign='top' height='100%' colspan='4'>");
            output.Write("<select id='" + ID + "_selected' class='scContentControlMultilistBox scSingleSelectWithSearchSelectedBox' size='10'" + str1 + ">");
            for (int index = 0; index < selected.Count; ++index)
            {
                Item obj1 = selected[index] as Item;
                if (obj1 != null)
                {
                    string str3 = OutputString(obj1);
                    output.Write("<option value='" + GetItemValue(obj1) + "'>" + str3 + "</option>");
                }
                else
                {
                    string path = selected[index] as string;
                    if (path != null)
                    {
                        Item   obj2 = Sitecore.Context.ContentDatabase.GetItem(path);
                        string str3 = obj2 == null ? path + ' ' + Translate.Text("[Item not found]") : OutputString(obj2);
                        output.Write("<option value='" + path + "'>" + str3 + "</option>");
                    }
                }
            }
            output.Write("</select>");
            output.Write("</td>");
            output.Write("</tr>");
            output.Write("<div style='border:1px solid #999999;font:8pt tahoma;display:none;padding:2px;margin:4px 0px 4px 0px;height:14px' id='" + ID + "_all_help'></div>");
            output.Write("<div style='border:1px solid #999999;font:8pt tahoma;display:none;padding:2px;margin:4px 0px 4px 0px;height:14px' id='" + ID + "_selected_help'></div>");
            output.Write("</table>");
            RenderScript(output);
        }
예제 #7
0
    void Update()
    {
        // Handle State
        if (playing)
        {
            switch (state)
            {
            case PlayerState.Idle:
                // Update Animator
                animator.SetBool("isCrouching", false);

                // Check for Crouch
                if (Input.GetKey(keybinds.W) || Input.GetKey(keybinds.A) || Input.GetKey(keybinds.S) || Input.GetKey(keybinds.D))
                {
                    state = PlayerState.Crouch;
                }

                // Stick to Log
                if (isSticking && stickObject != null)
                {
                    transform.position = stickObject.transform.position + stickPos;
                }

                // Look
                model.transform.rotation = Quaternion.Euler(0, direction * 90, 0);
                break;

            case PlayerState.Crouch:
                // Update Animator
                animator.SetBool("isCrouching", true);

                // Check for Jump
                if (Input.GetKeyUp(keybinds.W) || Input.GetKeyUp(keybinds.A) || Input.GetKeyUp(keybinds.S) || Input.GetKeyUp(keybinds.D))
                {
                    if (!Input.GetKey(keybinds.W) && !Input.GetKey(keybinds.A) && !Input.GetKey(keybinds.S) && !Input.GetKey(keybinds.D))
                    {
                        CheckMovement();

                        if (canMove)
                        {
                            state = PlayerState.Jump;
                            animator.SetTrigger("shouldJump");

                            StartJump();
                        }
                        else
                        {
                            state = PlayerState.Idle;
                        }
                    }
                }

                // Stick to Log
                if (isSticking && stickObject != null)
                {
                    transform.position = stickObject.transform.position + stickPos;
                }

                // Look
                model.transform.rotation = Quaternion.Euler(0, direction * 90, 0);
                break;

            case PlayerState.Jump:
                // Update Animator
                animator.SetBool("isCrouching", false);

                // Move
                transform.Translate(model.transform.forward * (1 / jumpSpeed) * Time.deltaTime);

                // Strafe to Tile
                if (direction == 0 || direction == 2)
                {
                    transform.Translate(Vector3.right * (jumpX / jumpSpeed) * Time.deltaTime);
                }

                // Check for Chaining
                if (Input.GetKeyUp(keybinds.W) || Input.GetKeyUp(keybinds.A) || Input.GetKeyUp(keybinds.S) || Input.GetKeyUp(keybinds.D))
                {
                    repeatJump = true;
                    animator.SetTrigger("shouldJump");
                }

                // Check for Crouch
                animator.SetBool("isCrouching", Input.GetKey(keybinds.W) || Input.GetKey(keybinds.A) || Input.GetKey(keybinds.S) || Input.GetKey(keybinds.D));
                break;
            }

            // Handle Looking
            if (Input.GetKey(keybinds.W))
            {
                direction = 0;
            }
            if (Input.GetKey(keybinds.A))
            {
                direction = 3;
            }
            if (Input.GetKey(keybinds.S))
            {
                direction = 2;
            }
            if (Input.GetKey(keybinds.D))
            {
                direction = 1;
            }

            // Detect Log Edge Deaths
            if (isSticking)
            {
                Translate script = stickObject.GetComponent <Translate>();

                if (script != null && script.boosting)
                {
                    state   = PlayerState.Dead;
                    playing = false;

                    StartCoroutine(gameController.PlayerDied(playerID));
                }
            }
        }
        else
        {
            // Dead
            if (state == PlayerState.Dead)
            {
                // Stick to the Object
                if (isSticking)
                {
                    transform.rotation            = Quaternion.Euler(0, direction * 90, 0);
                    model.transform.localRotation = Quaternion.Euler(0, 0, 0);

                    if (stickObject != null)
                    {
                        transform.position = stickObject.transform.position + stickPos;
                    }
                }
            }
        }
    }
예제 #8
0
        public void TranslateTo7_CharactorT()
        {
            Translate testLeetspeak = new Translate();

            Assert.AreEqual('7', testLeetspeak.TranslateToLeet('T'));
        }
예제 #9
0
        public void TranslateTo3_CharactorE()
        {
            Translate testLeetspeak = new Translate();

            Assert.AreEqual('3', testLeetspeak.TranslateToLeet('e'));
        }
예제 #10
0
        public ProgramWnd(ProgramID id)
        {
            InitializeComponent();

            this.Title = Translate.fmt("wnd_program");

            this.grpProgram.Header  = Translate.fmt("lbl_program");
            this.radProgram.Content = Translate.fmt("lbl_exe");
            this.radService.Content = Translate.fmt("lbl_svc");
            this.radApp.Content     = Translate.fmt("lbl_app");

            this.btnOK.Content     = Translate.fmt("lbl_ok");
            this.btnCancel.Content = Translate.fmt("lbl_cancel");

            ID = id;

            SuspendChange++;

            Paths = new ObservableCollection <PathEntry>();

            ListCollectionView lcv = new ListCollectionView(Paths);

            lcv.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
            cmbPath.ItemsSource = lcv;

            Paths.Add(new PathEntry()
            {
                Content = Translate.fmt("pro_browse"), Tag = "*", Group = Translate.fmt("lbl_selec")
            });
            PathEntry itemAll = new PathEntry()
            {
                Content = Translate.fmt("pro_all"), Tag = null, Group = Translate.fmt("lbl_selec")
            };

            Paths.Add(itemAll);

            if (ID != null && ID.Path.Length > 0)
            {
                PathEntry itemPath;
                if (ID.Path.Equals("system"))
                {
                    itemPath = new PathEntry()
                    {
                        Content = Translate.fmt("pro_sys"), Tag = ID.Path, Group = Translate.fmt("lbl_selec")
                    }
                }
                ;
                else
                {
                    itemPath = new PathEntry()
                    {
                        Content = ID.Path, Tag = ID.Path, Group = Translate.fmt("lbl_known")
                    }
                };
                Paths.Add(itemPath);
                cmbPath.SelectedItem = itemPath;
            }
            else
            {
                cmbPath.SelectedItem = itemAll;
            }

            //if (ID != null &&  ((ID.Path.Length == 0 && ID.Name.Length == 0) || ID.Path.Equals("system")))
            if (ID != null)
            {
                radProgram.IsEnabled = false;
                radService.IsEnabled = false;
                radApp.IsEnabled     = false;

                cmbPath.IsEnabled    = false;
                cmbService.IsEnabled = false;
                cmbApp.IsEnabled     = false;
            }

            cmbService.ItemsSource = ServiceModel.GetInstance().GetServices();
            cmbApp.ItemsSource     = AppModel.GetInstance().GetApps();

            if (ID == null)
            {
                radProgram.IsChecked = true;
                //ID = ProgramID.NewID(ProgramID.Types.Program);
            }
            else
            {
                switch (ID.Type)
                {
                case ProgramID.Types.Program:
                    radProgram.IsChecked = true;
                    cmbPath.Text         = ID.GetPath();
                    break;

                case ProgramID.Types.Service:
                    radService.IsChecked = true;
                    foreach (ServiceModel.Service service in cmbService.Items)
                    {
                        if (MiscFunc.StrCmp(service.Value, ID.GetServiceId()))
                        {
                            cmbService.SelectedItem = service;
                            break;
                        }
                    }
                    if (cmbService.SelectedItem == null)
                    {
                        cmbService.Text = ID.GetServiceId();
                    }
                    break;

                case ProgramID.Types.App:
                    radApp.IsChecked = true;
                    foreach (AppModel.AppPkg app in cmbApp.Items)
                    {
                        if (MiscFunc.StrCmp(app.Value, ID.GetPackageSID()))
                        {
                            cmbApp.SelectedItem = app;
                            break;
                        }
                    }
                    if (cmbApp.SelectedItem == null)
                    {
                        cmbApp.Text = ID.GetPackageSID();
                    }
                    break;
                }
            }

            if (UwpFunc.IsWindows7OrLower)
            {
                radApp.IsEnabled = false;
                cmbApp.IsEnabled = false;
            }

            SuspendChange--;
        }
예제 #11
0
        public void TranslateTo0_CharactorO()
        {
            Translate testLeetspeak = new Translate();

            Assert.AreEqual('0', testLeetspeak.TranslateToLeet('o'));
        }
예제 #12
0
    public void ShowEndButton()
    {
        //treści - Liczba punktów/skuteczność/liczba żyć       
        //LiveTxt.rectTransform.sizeDelta = new Vector2(LiveTxt.GetComponent<Text>().preferredWidth + 80, 70);
        //SuccesTxt.rectTransform.sizeDelta = new Vector2(LiveTxt.GetComponent<Text>().preferredWidth + 80, 70);
        //ScoreTxt.rectTransform.sizeDelta = new Vector2(LiveTxt.GetComponent<Text>().preferredWidth + 80, 70);
        // przyciski                
        translateComponentLeft = LeftButtonText.gameObject.AddComponent<Translate>();
        translateComponentRight = RightButtonText.gameObject.AddComponent<Translate>();
        trLeft = gameObject.AddComponent<Translations>();
        trRight = gameObject.AddComponent<Translations>();

        if (isTraining == IsTraining.NoTraining)
        {
            // ***** komentarze potrzebne do starej wersji treningów *****
            if (currentLevelStatus == LevelStatus.Fail)
            {
                if (failCount >= 3 && level > 1)
                {
                    LeftButton.gameObject.SetActive(true);
                    RightButton.gameObject.SetActive(true);
                    // again                    
                    translateComponentLeft.key = "statsRestart";
                    TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);
                    //prev
                    translateComponentRight.key = "statsPreviousLevel";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);
                }

                if (failCount < 3)
                {
                    //again
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "statsRestart";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);
                    LeftButton.gameObject.SetActive(false);
                }
                if (level == 1)
                {
                    //again
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "statsRestart";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);
                    LeftButton.gameObject.SetActive(false);
                }
            }
            if (currentLevelStatus == LevelStatus.Success)
            {
                if (level < 10)
                {
                    //again
                    LeftButton.gameObject.SetActive(true);
                    translateComponentLeft.key = "statsRestart";
                    TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);
                    //next
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "statsNextLevel";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);

                }
                else
                {
                    LeftButton.gameObject.SetActive(false);

                    //again
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "statsRestart";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);

                }
            }
        }
        if (isTraining == IsTraining.Inside)
        {
            
            if (currentLevelStatus == LevelStatus.Success)
            {
                if (level < 10)
                {
                    //next
                    //LeftButton.gameObject.SetActive(true);
                    //translateComponentLeft.key = "statsNextLevel";
                    //TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);

                    //continue
                    LeftButton.gameObject.SetActive(false);
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "continueTraining";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);

                }
                else
                { 
                    //continue
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "continueTraining";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);
                    LeftButton.gameObject.SetActive(false);
                    // again
                    //LeftButton.gameObject.SetActive(true);
                    //translateComponentLeft.key = "statsRestart";
                    //TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);
                }
            }
            if (currentLevelStatus == LevelStatus.Fail)
            {
                if (failCount >= 3 && level > 1)
                {
                    LeftButton.gameObject.SetActive(false);
                    RightButton.gameObject.SetActive(true);

                    //continue
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "continueTraining";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);

                    //prev
                    //translateComponentLeft.key = "statsPreviousLevel";
                    //TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);
                }

                if (failCount < 3)
                {
                    //continue
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "continueTraining";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);
                    LeftButton.gameObject.SetActive(false);
                   
                    // again
                    //translateComponentLeft.key = "statsRestart";                  
                   // TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);
                }
                if (level == 1)
                {
                    //continue
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "continueTraining";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);
                    LeftButton.gameObject.SetActive(false);

                    // again
                    //translateComponentLeft.key = "statsRestart";                    
                  //  TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);

                }
            }
        }
        else if (isTraining == IsTraining.Last)
        {
            
            if (currentLevelStatus == LevelStatus.Success)
            {
                if (level < 10)
                {
                    //next
                    //LeftButton.gameObject.SetActive(true);
                    //translateComponentLeft.key = "statsNextLevel";                    
                   // TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);
                    LeftButton.gameObject.SetActive(false);

                    //end
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "endTraining";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);

                }
                else
                {                    
                    //end
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "endTraining";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);
                    LeftButton.gameObject.SetActive(false);
                    // again
                    //LeftButton.gameObject.SetActive(true);
                    //translateComponentLeft.key = "statsRestart";                   
                    //TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);
                }
            }
            if (currentLevelStatus == LevelStatus.Fail)
            {
                if (failCount >= 3 && level > 1)
                {   
                    //end
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "endTraining";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);

                    LeftButton.gameObject.SetActive(false);
                    //prev
                    //translateComponentLeft.key = "statsPreviousLevel";
                    //TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);
                }

                if (failCount < 3)
                {
                    //end
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "endTraining";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);
                    LeftButton.gameObject.SetActive(false);
                   
                    // again
                    //translateComponentLeft.key = "statsRestart";
                    //TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);
                }
                if (level == 1)
                {
                    //end
                    RightButton.gameObject.SetActive(true);
                    translateComponentRight.key = "endTraining";
                    TranslateAndSizeButton(RightButton, RightButtonText, translateComponentRight, trRight);
                    LeftButton.gameObject.SetActive(false);

                    

                    // again
                    //translateComponentLeft.key = "statsRestart";
                   // TranslateAndSizeButton(LeftButton, LeftButtonText, translateComponentLeft, trLeft);

                }
            }
        }
    }
예제 #13
0
        public IEnumerable GetApps()
        {
            Apps.Clear();
            foreach (AppManager.AppInfo app in PrivateWin10.App.itf.GetAllApps())
            {
                Apps.Add(new App()
                {
                    Content = app.Name + " (" + app.ID + ")", Value = app.SID, Group = Translate.fmt("lbl_known")
                });
            }

            ListCollectionView lcv = new ListCollectionView(Apps);

            lcv.GroupDescriptions.Add(new PropertyGroupDescription("Group"));
            return(lcv);
        }
예제 #14
0
파일: Entity.cs 프로젝트: ritro/White
        private string BuildStringRepresentation(Translate translate)
        {
            var builder = new StringBuilder();
            foreach (var fieldInfo in GetType().GetFields(BindingFlag))
            {
                if (fieldInfo.GetCustomAttributes(typeof(ScreenIgnoreAttribute), false).Length != 1)
                    builder.Append(translate(fieldInfo));
            }

            return builder.ToString();
        }
        /// <summary>
        /// タイトル等データをセット
        /// </summary>
        public override void SetTitleData( DataRow row ,
                                      Text.TextData textData ,
                                      Translate.TranslateText translateText )
        {
            Text.TextDataStoryDefs tData = (Text.TextDataStoryDefs)textData;
            Translate.TranslateTextStoryDefs tText = ( Translate.TranslateTextStoryDefs ) translateText;

            if ( row.RowState == DataRowState.Added || row.RowState == DataRowState.Detached )
            {
                // サイエンスレポートID
                this.SetDataValue( row , ColumnNameTitle , tData.Title );

                // サイエンスレポートResultText
                this.SetDataValue( row , ColumnNameNoteText , tText.TextNode.TextTitle );

                // サイエンスレポートResultIndex
                this.SetDataValue( row , ColumnNameNoteIndex , tText.TextNode.TextIndex );
            }
        }
예제 #16
0
        private void EmitProcess(Translate.ProcFrag f)
        {
            //
            //Temp.TempMap map = new Temp.CombineMap(f.Frame, new Temp.DefaultMap());
            //Tree.Print pt = new Tree.Print(_writer, map);
            //pt.PrintStm(f.Body);
            //

            Tree.StmList stms = Canon.Canon.Linearize(f.Body);
            Canon.BasicBlocks b = new Canon.BasicBlocks(stms);
            Tree.StmList traced = (new Canon.TraceSchedule(b)).Stms;
            Quadruple.Quadruple threeAddr = new Quadruple.Quadruple(f.Frame as Mips.MipsFrame);
            threeAddr.CodeGenerate(traced);
            threeAddr.InstrList = (f.Frame as Mips.MipsFrame).ProcessEntryExit2(threeAddr.InstrList);

            Block.BuildBlocks buildBlocks = new Block.BuildBlocks(threeAddr.InstrList);
            //
            //Quadruple.Print print = new Quadruple.Print(_writer);
            //print.print(buildBlocks.Blocks);
            //
            RegisterAllocate.RegisterAllocate reg = new RegisterAllocate.RegisterAllocate((f.Frame as Mips.MipsFrame), buildBlocks.Blocks, f.Frame.Registers());
            reg.Allocate();

            List<Quadruple.TExp> instrList = new List<Quadruple.TExp>();
            foreach (Block.BasicBlock blk in reg.Blocks)
            {
                instrList.AddRange(blk.List);
            }
            instrList = (f.Frame as Mips.MipsFrame).ProcessEntryExit3(instrList);
            CodeGenerate.CodeGen gen = new CodeGenerate.CodeGen(instrList, reg.TempToNode, (f.Frame as Mips.MipsFrame));

            gen.CodeGenerate(_writer);
        }
예제 #17
0
 /// <summary>
 /// タイトル等データをセット
 /// </summary>
 public abstract void SetTitleData( DataRow row ,
                      Text.TextData textData ,
                      Translate.TranslateText translateText );
예제 #18
0
 /// <summary>
 /// DBに存在するかチェック
 /// </summary>
 public abstract DataRow[] GetExistsDataRow( string directoryName ,
                                             Text.TextData textData ,
                                             Translate.TranslateText translateText );
예제 #19
0
        private string BuildStringRepresentation(Translate translate)
        {
            StringBuilder builder = new StringBuilder();
            Class @class = new Class(GetType());
            @class.EachField(delegate(FieldInfo fieldInfo)
                                 {
                                     if (fieldInfo.GetCustomAttributes(typeof (ScreenIgnoreAttribute), false).Length != 1)
                                         builder.Append(translate(fieldInfo));
                                 });

            return builder.ToString();
        }
예제 #20
0
 public void TranslateAndSizeButton(Button btn, Text txt, Translate translateComponent, Translations tr)
 {
     txt.text = tr.Get(translateComponent.key);
     btn.image.rectTransform.sizeDelta = new Vector2(btn.GetComponentInChildren<Text>().preferredWidth + spaceWidth, spaceHeight);
 }
예제 #21
0
 private void btnReset_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(Translate.GetTranslate("frmSettings", "RESET_MESSAGE"), Translate.GetTranslate("frmSettings", "RESET_TITLE"), MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         Properties.Settings.Default.Reset();
         Application.Restart();
     }
 }
예제 #22
0
 public static Translate CreateTranslate(int id, int moduleItemID, string moduleItemField)
 {
     Translate translate = new Translate();
     translate.ID = id;
     translate.ModuleItemID = moduleItemID;
     translate.ModuleItemField = moduleItemField;
     return translate;
 }
예제 #23
0
        public AlbumEditViewModel()
        {
            AllDiscTypes = Translate.DiscTypeNames.ValuesAndNamesStrings;

            DiscTypeDescriptions = ViewRes.Album.EditStrings.BaDiscTypeExplanation
                                   + "<br /><br /><ul>" + string.Join("",
                                                                      EnumVal <DiscType> .Values.Where(v => v != DiscType.Unknown).Select(v => string.Format("<li><strong>{0}</strong>: {1}</li>",
                                                                                                                                                             Translate.DiscTypeName(v), global::Resources.DiscTypeDescriptions.ResourceManager.GetString(v.ToString()))));
        }
예제 #24
0
 public void AddToTranslates(Translate translate)
 {
     base.AddObject("Translates", translate);
 }
예제 #25
0
파일: Program.cs 프로젝트: Beraliv/Csharp
        public static void Menu()
        {
            bool exit = false;
            string line;
            string grammar = null;
            Translate tr = new Translate();

            Console.WriteLine("Functions: ");
            Console.WriteLine("In order to set the grammar");
            Console.WriteLine("> G <rules>");
            Console.WriteLine("Ex: G S:(A,B). A:(B,'a';@). B:(C,'b';C). C:('c';@). EOGram!");
            Console.WriteLine("In order to calculate FIRST");
            Console.WriteLine("> first <k>");
            Console.WriteLine("Example: first 2");
            Console.WriteLine("In order to calcualte EFF");
            Console.WriteLine("> eff <k>");
            Console.WriteLine("Example: eff 3");
            Console.WriteLine("In order to exit the program");
            Console.WriteLine("> e - exit");
            Console.Write("> ");

            while (!exit)
            {
                line = Console.ReadLine();

                if (line.Length > 0)
                {
                    if (line.Length == 1 && line[0] == 'e')
                        exit = true;
                    else
                    {
                        List<string> parts = line.Split(' ').Where(x => x != "").ToList();
                        string fun = parts[0];

                        switch (fun)
                        {
                            case "G":
                                if (grammar == null)
                                    grammar = tr.ToMyForm(line, Translate.TYPE.GRAMMAR);
                                else
                                {
                                    Console.WriteLine("Rewrite? y/n: ");
                                    string answer = Console.ReadLine();
                                    if (answer[0] == 'y')
                                        grammar = tr.ToMyForm(line, Translate.TYPE.GRAMMAR);
                                }
                                break;
                            case "first":
                            case "eff":
                                if (grammar == null)
                                    Console.WriteLine("error: no grammar");
                                else
                                {
                                    int k;
                                    IEnumerable<string> rules = grammar.Split(' ');
                                    List<Pair<char, string>> func_rules = new List<Pair<char, string>>();

                                    if (!int.TryParse(parts[1], out k))
                                    {
                                        Console.WriteLine("error: incorrect number of k: " + parts[1]);
                                        return;
                                    }
                                    else if (k <= 0)
                                    {
                                        Console.WriteLine("error: " + k + " must be greater than 0");
                                        return;
                                    }

                                    foreach (string rule in rules)
                                    {
                                        IEnumerable<string> parts_of_rule = rule.Split('>');

                                        if (parts_of_rule.Count() != 2)
                                        {
                                            Console.WriteLine("error: " + rule + " must have two parts");
                                            return;
                                        }

                                        if (parts_of_rule.ElementAt(0).Length != 1)
                                        {
                                            Console.WriteLine("error: the left part of " + rule + " must be non-terminal");
                                            return;
                                        }

                                        char left_part = parts_of_rule.ElementAt(0)[0];

                                        foreach (string right_part in parts_of_rule.ElementAt(1).Split('|'))
                                            if (right_part == "")
                                            {
                                                Console.WriteLine("error: " + rule + " mustn\'t have the empty argument");
                                                return;
                                            }
                                            else
                                                func_rules.Add(new Pair<char, string>(left_part, right_part));
                                    }

                                    Console.WriteLine("Ex: S");
                                    Console.WriteLine("Input sequence: ");
                                    Console.Write("> ");
                                    string sequence = tr.ToMyForm(Console.ReadLine(), Translate.TYPE.SEQUENCE);

                                    if (fun == "first")
                                    {
                                        First first = new First(k, Auxiliary.StrK('A', tr.Table.Count), tr.Terms.ToString(), func_rules);
                                        Console.WriteLine(first.Execute(sequence).ToString());
                                        break;
                                    }
                                    else
                                    {
                                        Eff eff = new Eff(k, Auxiliary.StrK('A', tr.Table.Count), tr.Terms.ToString(), func_rules);
                                        Console.WriteLine(eff.Execute(sequence).ToString());
                                        break;
                                    }
                                }
                                break;
                        }
                    }
                }
                else
                    Console.WriteLine("Try again\n");
                Console.Write("> ");
            }
        }
        /// <summary>
        /// タイトル等データをセット
        /// </summary>
        public override void SetTitleData( DataRow row ,
                                      Text.TextData textData ,
                                      Translate.TranslateText translateText )
        {
            Text.TextDataScienceDefs tData = (Text.TextDataScienceDefs)textData;
            Translate.TranslateTextScienceDefs tText = ( Translate.TranslateTextScienceDefs ) translateText;

            if ( row.RowState == DataRowState.Added || row.RowState == DataRowState.Detached )
            {
                // サイエンスレポートID
                this.SetDataValue( row , ColumnNameID , tData.ID );

                // サイエンスレポートResultText
                this.SetDataValue( row , ColumnNameResultText , tText.Result.ResultText );

                // サイエンスレポートResultIndex
                this.SetDataValue( row , ColumnNameResultIndex , tText.Result.ResultIndex );
            }

            // サイエンスレポートタイトル
            this.SetDataValue( row , ColumnNameTitle , tData.Title );
        }
예제 #27
0
        public void TranslateTo1_CharactorCapI()
        {
            Translate testLeetspeak = new Translate();

            Assert.AreEqual('1', testLeetspeak.TranslateToLeet('I'));
        }
예제 #28
0
    private SkillData _FindPoints( AnimationClip clip, float interval)
    {
        var data = new SkillData();

        var go = _Player as GameObject;

        var marks = go.GetComponentsInChildren<DeterminationExportMark>();
        var markLeft = (from m in marks where m.Part == DeterminationExportMark.PART.LEFT select m).Single();
        var markRight = (from m in marks where m.Part == DeterminationExportMark.PART.RIGHT select m).Single();
        var markRoot = (from m in marks where m.Part == DeterminationExportMark.PART.ROOT select m).Single();
        var len = clip.length;

        List<Vector2> left = new List<Vector2>();
        List<Vector2> right = new List<Vector2>();
        List<Translate> root = new List<Translate>();

        float eulerAngle = go.transform.rotation.eulerAngles.y;
        var rootPosition = new Vector2(go.transform.position.x, go.transform.position.z);
        var basePosition = markRoot.Position;
        Debug.Log("basePosition  : " + basePosition);
        for (var i = 0.0f ; i < len; i += interval)
        {
            clip.SampleAnimation(go, i);

            var currentposition = markRoot.Position - basePosition ;
            var position = currentposition;
            var y = go.transform.rotation.eulerAngles.y;
            var t = new Translate()
            {
                Position = new Regulus.CustomType.Vector2(position.x, position.y),
                Rotation = eulerAngle - y
            };

            root.Add(t);
            eulerAngle = y;
            if (i >= _BeginTime && i <= _EndTime)
            {
                left.Add(markLeft.Position - rootPosition  );

                right.Add(markRight.Position - rootPosition );
            }
        }
        data.Lefts = (from l in left select new Regulus.CustomType.Vector2(l.x, l.y)).ToArray();
        data.Rights = (from r in right select new Regulus.CustomType.Vector2(r.x, r.y)).ToArray();
        data.Roots = root.ToArray();
        data.Total = len;
        data.Begin = _BeginTime;
        data.End = _EndTime;

        return data;
    }
예제 #29
0
        public void TranslateToZ_CharactorS()
        {
            Translate testLeetspeak = new Translate();

            Assert.AreEqual('z', testLeetspeak.TranslateToLeet('s'));
        }
예제 #30
0
        public RuleWindow(List <Program> progs, FirewallRule rule)
        {
            InitializeComponent();

            this.Title = Translate.fmt("wnd_rule");

            this.grpRule.Header = Translate.fmt("lbl_rule");
            this.lblName.Text   = Translate.fmt("lbl_name");
            this.lblGroup.Text  = Translate.fmt("lbl_group");

            this.grpProgram.Header  = Translate.fmt("lbl_program");
            this.lblProgram.Text    = Translate.fmt("lbl_program");
            this.lblExecutable.Text = Translate.fmt("lbl_exe");
            this.lblService.Text    = Translate.fmt("lbl_svc");
            this.lblApp.Text        = Translate.fmt("lbl_app");

            this.grpAction.Header = Translate.fmt("grp_action");
            this.lblAction.Text   = Translate.fmt("lbl_action");

            this.radProfileAll.Content    = Translate.fmt("lbl_prof_all");
            this.radProfileCustom.Content = Translate.fmt("lbl_prof_sel");
            this.chkPublic.Content        = Translate.fmt("lbl_prof_pub");
            this.chkDomain.Content        = Translate.fmt("lbl_prof_dmn");
            this.chkPrivate.Content       = Translate.fmt("lbl_prof_priv");

            this.radNicAll.Content    = Translate.fmt("lbl_itf_all");
            this.radNicCustom.Content = Translate.fmt("lbl_itf_select");
            this.chkLAN.Content       = Translate.fmt("lbl_itf_lan");
            this.chkVPN.Content       = Translate.fmt("lbl_itf_vpn");
            this.chkWiFi.Content      = Translate.fmt("lbl_itf_wifi");

            this.grpNetwork.Header = Translate.fmt("grp_network");
            this.lblDirection.Text = Translate.fmt("lbl_direction");
            this.lblProtocol.Text  = Translate.fmt("lbl_protocol");

            this.lblLocalPorts.Text  = Translate.fmt("lbl_local_port");
            this.lblRemotePorts.Text = Translate.fmt("lbl_remote_port");

            this.lblICMP.Text = Translate.fmt("lbl_icmp");

            this.lblLocalIP.Text  = Translate.fmt("lbl_local_ip");
            this.lblRemoteIP.Text = Translate.fmt("lbl_remote_ip");

            this.btnOK.Content     = Translate.fmt("lbl_ok");
            this.btnCancel.Content = Translate.fmt("lbl_cancel");

            Rule = rule;
            bool bNew = Rule.guid == null;

            viewModel   = new RuleWindowViewModel();
            DataContext = viewModel;

            //txtName.Text = Rule.Name;
            viewModel.RuleName   = Rule.Name;
            cmbGroup.ItemsSource = GroupModel.GetInstance().GetGroups();
            if (!WpfFunc.CmbSelect(cmbGroup, Rule.Grouping))
            {
                cmbGroup.Text = Rule.Grouping;
            }
            txtInfo.Text = Rule.Description;

            foreach (Program prog in progs)
            {
                ContentControl program = new ContentControl()
                {
                    Content = prog.Description, Tag = prog.ID
                };
                cmbProgram.Items.Add(program);
                if (Rule.ProgID != null && prog.ID.CompareTo(Rule.ProgID) == 0)
                {
                    cmbProgram.SelectedItem = program;
                }
            }

            cmbAction.Items.Add(new ContentControl()
            {
                Content = Translate.fmt("str_allow"), Tag = FirewallRule.Actions.Allow
            });
            cmbAction.Items.Add(new ContentControl()
            {
                Content = Translate.fmt("str_block"), Tag = FirewallRule.Actions.Block
            });
            //WpfFunc.CmbSelect(cmbAction, Rule.Action.ToString());
            viewModel.RuleAction = WpfFunc.CmbPick(cmbAction, Rule.Action.ToString());

            if (Rule.Profile == (int)FirewallRule.Profiles.All)
            {
                radProfileAll.IsChecked = true;
                chkPrivate.IsChecked    = true;
                chkDomain.IsChecked     = true;
                chkPublic.IsChecked     = true;
            }
            else
            {
                radProfileCustom.IsChecked = true;
                chkPrivate.IsChecked       = ((Rule.Profile & (int)FirewallRule.Profiles.Private) != 0);
                chkDomain.IsChecked        = ((Rule.Profile & (int)FirewallRule.Profiles.Domain) != 0);
                chkPublic.IsChecked        = ((Rule.Profile & (int)FirewallRule.Profiles.Public) != 0);
            }

            if (Rule.Interface == (int)FirewallRule.Interfaces.All)
            {
                radNicAll.IsChecked = true;
                chkLAN.IsChecked    = true;
                chkVPN.IsChecked    = true;
                chkWiFi.IsChecked   = true;
            }
            else
            {
                radNicCustom.IsChecked = true;
                chkLAN.IsChecked       = ((Rule.Interface & (int)FirewallRule.Interfaces.Lan) != 0);
                chkVPN.IsChecked       = ((Rule.Interface & (int)FirewallRule.Interfaces.RemoteAccess) != 0);
                chkWiFi.IsChecked      = ((Rule.Interface & (int)FirewallRule.Interfaces.Wireless) != 0);
            }

            if (bNew)
            {
                cmbDirection.Items.Add(new ContentControl()
                {
                    Content = Translate.fmt("str_inandout"), Tag = FirewallRule.Directions.Bidirectiona
                });
            }
            cmbDirection.Items.Add(new ContentControl()
            {
                Content = Translate.fmt("str_outbound"), Tag = FirewallRule.Directions.Outboun
            });
            cmbDirection.Items.Add(new ContentControl()
            {
                Content = Translate.fmt("str_inbound"), Tag = FirewallRule.Directions.Inbound
            });
            WpfFunc.CmbSelect(cmbDirection, Rule.Direction.ToString());

            cmbProtocol.Items.Add(new ContentControl()
            {
                Content = Translate.fmt("pro_any"), Tag = (int)NetFunc.KnownProtocols.Any
            });
            for (int i = (int)NetFunc.KnownProtocols.Min; i <= (int)NetFunc.KnownProtocols.Max; i++)
            {
                string name = NetFunc.Protocol2Str((UInt32)i);
                if (name != null)
                {
                    cmbProtocol.Items.Add(new ContentControl()
                    {
                        Content = i.ToString() + " - " + name, Tag = i
                    });
                }
            }
            //if (!WpfFunc.CmbSelect(cmbProtocol, Rule.Protocol.ToString()))
            //    cmbProtocol.Text = Rule.Protocol.ToString();
            viewModel.Protocol = WpfFunc.CmbPick(cmbProtocol, Rule.Protocol.ToString());
            if (viewModel.Protocol == null)
            {
                viewModel.ProtocolTxt = Rule.Protocol.ToString();
            }

            UpdatePorts();

            addrDest.Address = Rule.RemoteAddresses;
            addrSrc.Address  = Rule.LocalAddresses;

            WpfFunc.LoadWnd(this, "Rule");
        }
예제 #31
0
        public bool ProcessCCListRBC()
        {
            SolutionTraceClass.WriteLineVerbose("Start");
            if (isStagingSaved == true)
            {
                return(true);
            }
            if (string.IsNullOrEmpty(archiveFileName))
            {
                return(false);
            }

            StreamReader fr      = null;
            int          counter = 0;

            try
            {
                DateTime   now            = DateTime.Now.Date;
                Translate  trns           = new Translate();
                UnitOfWork myUnitOfWork   = new UnitOfWork();
                var        oldStagingList = myUnitOfWork.TblRBCCreditorListStagingRepository;

                using (fr = new StreamReader(archiveFileName, Encoding.Default, true))
                {
                    string s;
                    // INSERT and UPDATE Staging
                    while (!string.IsNullOrEmpty(s = fr.ReadLine()))
                    {
                        counter++;
                        if (s.Length != 4349)  // discuss if this value should be configurable...
                        {
                            // exclude only corrupted creditors :)
                            string msg = "***** Line #" + counter + "[CompanyID=" + (s.Length > 6 ? s.Substring(0, 6) : "???") + "] has length=" + s.Length + ", must be " + 4349;
                            SolutionTraceClass.WriteLineError(String.Format("Invalid RBC " + System.IO.Path.GetFileName(archiveFileName) + " file data.  Message was->{0}", msg));
                            LoggingHelper.LogAuditingActivity(msg);
                            //throw new InvalidDataException();
                            continue;
                        }
                        RBCPayeeListBodyDataValues datavalue = new RBCPayeeListBodyDataValues();
                        RBCPayeeListFileBodyProcessor <RBCPayeeListBodyDataValues> process = new RBCPayeeListFileBodyProcessor <RBCPayeeListBodyDataValues>(datavalue);
                        process.DeserializeFromString(s, ref datavalue);
                        updCounter++;
                        tblRBCCreditorListStaging row = trns[datavalue]; // ACTUALLY HERE SHOULD HAPPEN VALIDATION!!
                        row.NumberRetried = -1;                          // Mark as existing - NO UPDATE!!
                        tblRBCCreditorListStaging rowOld = oldStagingList.GetByID(row.CompanyID);
                        if (rowOld != null)
                        {
                            if (row.EffectiveDate.Date <= now && rowOld.EffectiveDate.Date < row.EffectiveDate.Date) // candidates for UPDATE
                            {
                                row.NumberRetried = -2;                                                              // Mark as existing to overwrite later
                                //1. Y->N
                                if (row.CurrentRecord.Contains('Y') && rowOld.CurrentRecord.Contains('N') && !row.AccountNumberEditRules.Contains('D'))
                                {
                                    row.CurrentRecord = "E"; // El. Delivery + CurRec->'Y'
                                }
                                //2. N->Y
                                else if (row.CurrentRecord.Contains('N') && rowOld.CurrentRecord.Contains('Y'))
                                {
                                    row.CurrentRecord = "C"; // cheque + CurRec->'N'
                                }
                                else if (row.AccountNumberEditRules.Contains('D'))
                                {
                                    row.CurrentRecord = row.CurrentRecord.Contains('N') ? "P" : "Q"; // Cheque
                                }
                                else if (!row.AccountNumberEditRules.Contains('D') && rowOld.AccountNumberEditRules.Contains('D'))
                                {
                                    row.CurrentRecord = row.CurrentRecord = row.CurrentRecord.Contains('N') ? "D" : "L"; // El. Delivery
                                }
                                Translate.UpdateRow(row, rowOld);
                                //rowOld.Assign(row);
                                // oldStagingList.Update(row);
                            }
                        }
                        else
                        {
                            row.NumberRetried = -3; // Mark as new to overwrite later
                            oldStagingList.Insert(row);
                        }
                    }
                    // DELETE from Staging records not in CC List
                    myUnitOfWork.Save();  // The 2-nd transactionwe ALMOST done with the Staging!!
                    archiveFileName = "";
                    isStagingSaved  = true;
                }
                SolutionTraceClass.WriteLineVerbose("End");
                return(updCounter > 0);
            }
            catch (Exception ex)
            {
                numOfRetried++;
                SolutionTraceClass.WriteLineError(String.Format("Exception.  Message was->{0}", ex.Message));
                LoggingHelper.LogErrorActivity(ex);
                return(false);
            }
            finally
            {
                if (fr != null)
                {
                    fr.Dispose();
                }
            }
        }
예제 #32
0
        private void main_form_timer_Tick(object sender, EventArgs e)
        {
            try
            {
                string server_message = "";

                if (main_form_timer.Enabled == false || !Program.MainIsRunning)
                {
                    return;
                }
                main_form_timer.Enabled = false;

                if (string.IsNullOrEmpty(Program.UserName))
                {
                    lblTime.Text = $"{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}";
                }
                else
                {
                    lblTime.Text = $"{DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()} - {Program.UserName}";
                }

                try
                {
                    var last = Main.Database.FirstOrDefault <SqlDbMonitor>("SELECT TOP 1 * FROM Monitor WITH(NOLOCK) WHERE Software='ProcessServer' ORDER BY LastRead DESC");
                    if (last != null)
                    {
                        if (last.LastRead.AddMinutes(3) < DateTime.UtcNow)
                        {
                            lbl_StatusServer.BackColor = System.Drawing.Color.Red;
                        }
                        else
                        {
                            lbl_StatusServer.BackColor = panel2.BackColor;
                        }

                        if (!string.IsNullOrEmpty(last.Version) && lblServerVersion.Text != last.Version)
                        {
                            lblServerVersion.Text = last.Version;
                        }

                        if (!string.IsNullOrEmpty(last.Message))
                        {
                            server_message = " " + (last.Message ?? "");
                        }
                        else
                        {
                            server_message = "";
                        }

                        if (lblServerVersion.Font.Size > 7)
                        {
                            lblServerVersion.Font = new Font(lblServerVersion.Font.FontFamily, 7.0f);
                        }
                    }
                }
                catch (Exception ex)
                {
                    lbl_StatusServer.BackColor = System.Drawing.Color.Red;
                    log.Error($"error reading monitor data (no connection to database)", ex);
                }

                string status        = "";
                string status_active = "";
                //string status_ok = "";
                int    stations_ok      = 0;
                int    stations_err     = 0;
                bool   blocked          = false;
                bool   blocked_all      = false;
                string status_blocked   = "";
                bool   any_error        = false;
                var    maint            = new Dictionary <int, bool>();
                string maintenance_text = "";

                var units = Main.Database.Fetch <Unit>("SELECT * FROM Units WITH(NOLOCK) WHERE Unit_ID <> 99 ORDER BY Ident");
                foreach (var item in units)
                {
                    if (item.HasError)
                    {
                        any_error = true;
                    }

                    if (item.Unit_ID == 10) // Main Rack !
                    {
                        if ((item.ErrorWord10 & 4096) != 0)
                        {
                            maint[21] = true;
                        }
                        else
                        {
                            if (!item.Online)
                            {
                                any_error = true;
                            }
                        }
                        if ((item.ErrorWord10 & 8192) != 0)
                        {
                            maint[22] = true;
                        }
                        else
                        {
                            if (!item.Online)
                            {
                                any_error = true;
                            }
                        }
                        if ((item.ErrorWord10 & 16384) != 0)
                        {
                            maint[23] = true;
                        }
                        else
                        {
                            if (!item.Online)
                            {
                                any_error = true;
                            }
                        }
                    }
                }

                foreach (var item in units)
                {
                    if (right_side_only && item.Number == 13)
                    {
                        continue;
                    }
                    if (right_side_only && item.Number == 23)
                    {
                        continue;
                    }

                    string name = item.Ident.Replace("+ST01.", "");
                    name = name.Replace("LS0", "IO");
                    name = name.Replace("SC0", "TR");
                    name = name.Replace("CAR0", "CR");
                    name = name.Replace("BU", "Main");

                    if (item.HasError)
                    {
                        status += name + ":" + Translate.TranslateString("ERROR");
                        stations_err++;
                    }
                    else if (maint.ContainsKey(item.Unit_ID) && maint[item.Unit_ID] == true)
                    {
                        // status += name + ":" + Translate.TranslateString("maintenance");
                        maintenance_text += " " + name + ":" + Translate.TranslateString("maintenance");
                    }
                    else if (item.Active)
                    {
                        stations_ok++;
                        if (name == "IO1" || name == "IO2")
                        {
                            status        += name + ":" + Translate.TranslateString("active");
                            status_active += name + ":" + Translate.TranslateString("active");
                        }
                        else
                        {
                            status        += name + ":" + Translate.TranslateString("moving");
                            status_active += name + ":" + Translate.TranslateString("moving");
                        }
                    }
                    else if (item.Ready)
                    {
                        stations_ok++;
                        if (any_error)
                        {
                            status += name + ":" + Translate.TranslateString("ready");
                        }
                    }
                    else if (item.Online)
                    {
                        if (any_error)
                        {
                            status += name + ":" + Translate.TranslateString("online");
                        }
                    }
                    else if (!item.Ready)
                    {
                        status += name + ":" + Translate.TranslateString("not ready");
                        stations_err++;
                    }
                    else
                    {
                        status += name + ":" + Translate.TranslateString("manual");
                    }
                    status += " ";

                    if (item.BlockForManualOrderUntil >= DateTime.UtcNow)
                    {
                        blocked = true;
                        if ((item.BlockForManualOrderUntil - DateTime.UtcNow).TotalSeconds >= 60)
                        {
                            status_blocked = $"{item.FriendlyName} accepting manual moves for {(item.BlockForManualOrderUntil - DateTime.UtcNow).TotalMinutes} minutes";
                        }
                    }
                    if (item.BlockForManualOrderUntil >= DateTime.UtcNow.AddDays(7))
                    {
                        blocked_all    = true;
                        status_blocked = "All stations blocked for manual movements";
                    }
                }

                if (!string.IsNullOrEmpty(server_message))
                {
                    lbl_StatusAll.BackColor = Color.Orange;
                    status += server_message;
                }
                else
                {
                    lbl_StatusAll.BackColor = any_error || messagesTabControl.isError ? Color.Red : (blocked ? (blocked_all ? Color.Orange : Color.LightBlue) : Color.WhiteSmoke);
                }

                if (stations_err == 0 && !any_error && stations_ok >= (9 - (right_side_only ? 2 : 0)))
                {
                    if (status_active != "")
                    {
                        status = status_active + maintenance_text + server_message;
                    }
                    else
                    {
                        status = "All stations ready" + maintenance_text + server_message;
                    }
                }
                status = status.Trim();

                if ((blocked || blocked_all) && status_blocked != "" && (status == "" || status == "All stations ready"))
                {
                    status = status_blocked;
                }

                if (lbl_StatusAll.Text != status)
                {
                    lbl_StatusAll.Text = status;
                }


                if (messagesTabControl != null)
                {
                    Color nextColor = Color.WhiteSmoke;

                    //if (messagesTabControl.isMessage)
                    //    nextColor = Color.YellowGreen;
                    if (messagesTabControl.isWarning)
                    {
                        nextColor = Color.Orange;
                    }
                    if (messagesTabControl.isError)
                    {
                        nextColor = Color.Red;
                    }

                    if (btnAlarm.InnerFillColor != nextColor)
                    {
                        btnAlarm.InnerFillColor = nextColor;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("error in main_form_timer", ex);
            }
            main_form_timer.Enabled = true;
        }
예제 #33
0
        private void LoadCurrent(bool bUpdate = false)
        {
            if (!bUpdate)
            {
                ProgramSet.Config.AccessLevels NetAccess = ProgramSet.Config.AccessLevels.Unconfigured;

                cmbAccess.Background = ProgramControl.GetAccessColor(NetAccess);
                WpfFunc.CmbSelect(cmbAccess, NetAccess.ToString());
            }

            btnApply.IsEnabled = false;

            ProgramID id = mEventList.ElementAt(curIndex);
            Tuple <Program, List <Engine.FwEventArgs> > list = mEvents[id];

            //int PID = list.Item2.Count > 0 ? list.Item2.First().FwEvent.ProcessId : 0;
            string FilePath = list.Item2.Count > 0 ? list.Item2.First().entry.FwEvent.ProcessFileName : "";

            imgIcon.Source = ImgFunc.GetIcon(FilePath, imgIcon.Width); // todo: use .progSet.GetIcon instead?
            //lblName.Text = id.GetDisplayName(false);
            grpBox.Header = list.Item1.Description;
            //lblPID.Text = string.Format("{0} ({1})", System.IO.Path.GetFileName(id.Path), PID);
            lblPID.Text = System.IO.Path.GetFileName(id.Path);

            List <string> services = new List <string>();

            consGrid.Items.Clear();
            foreach (Engine.FwEventArgs args in list.Item2)
            {
                consGrid.Items.Insert(0, new ConEntry(args.entry));

                if (args.services != null)
                {
                    foreach (var service in args.services)
                    {
                        if (!services.Contains(service))
                        {
                            services.Add(service);
                        }
                    }
                }
            }

            if (services.Count > 0)
            {
                cmbService.Visibility = Visibility.Visible;
                cmbService.Items.Clear();
                foreach (var service in services)
                {
                    cmbService.Items.Add(service);
                }
                cmbService.SelectedIndex = -1;
                cmbService.Text          = Translate.fmt("msg_pick_svc");
            }
            else
            {
                cmbService.Visibility = Visibility.Collapsed;
                switch (id.Type)
                {
                //case ProgramList.Types.Program: lblSubName.Text = ""; break;
                case ProgramID.Types.Service: lblSubName.Text = id.GetServiceId(); break;

                case ProgramID.Types.App: lblSubName.Text = id.GetPackageName(); break;

                default: lblSubName.Text = ""; break;
                }
            }
            lblPath.Text = id.Path;
        }
예제 #34
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Some changes may start working only after application restart.");
            /// General
            Properties.Settings.Default.CastingDelay = int.Parse(txtCastDelay.Text);
            Properties.Settings.Default.LootingDelay = int.Parse(txtLootingDelay.Text);
            Properties.Settings.Default.FishWait     = int.Parse(txtFishWait.Text);

            /// Finding the Cursor
            Properties.Settings.Default.ScanningDelay    = int.Parse(txtDelay.Text);
            Properties.Settings.Default.ScanningRetries  = int.Parse(txtRetries.Text);
            Properties.Settings.Default.ScanningSteps    = int.Parse(txtScanSteps.Text);
            Properties.Settings.Default.CheckCursor      = cmbCompareIcon.Checked;
            Properties.Settings.Default.AlternativeRoute = cmbAlternativeRoute.Checked;
            Properties.Settings.Default.customScanArea   = customAreaCheckbox.Checked;

            /// Hearing the Fish
            Properties.Settings.Default.SplashLimit  = int.Parse(txtSplash.Text);
            Properties.Settings.Default.AudioDevice  = (string)cmbAudio.SelectedValue;
            Properties.Settings.Default.AverageSound = cbSoundAvg.Checked;

            /// Premium Settings

            Properties.Settings.Default.ProcName       = txtProcName.Text;
            Properties.Settings.Default.AutoLure       = cbAutoLure.Checked;
            Properties.Settings.Default.SwapGear       = cbHearth.Checked;
            Properties.Settings.Default.UseAltKey      = cbAlt.Checked;
            Properties.Settings.Default.RightClickCast = cbDblRclickCast.Checked;

            Properties.Settings.Default.FishKey    = txtFishKey.Text;
            Properties.Settings.Default.LureKey    = txtLureKey.Text;
            Properties.Settings.Default.HearthKey  = txtHearthKey.Text;
            Properties.Settings.Default.AutoHearth = cbHearth.Checked;

            // MoP Premium (Angler's Raft & Ancient Pandaren Fishing Charm)
            Properties.Settings.Default.CharmKey  = txtCharmKey.Text;
            Properties.Settings.Default.RaftKey   = txtRaftKey.Text;
            Properties.Settings.Default.AutoRaft  = cbApplyRaft.Checked;
            Properties.Settings.Default.AutoCharm = cbApplyCharm.Checked;
            Properties.Settings.Default.ShiftLoot = cbShiftLoot.Checked;

            // WoD Premium (Bait)
            Properties.Settings.Default.BaitKey1             = txtBaitKey1.Text;
            Properties.Settings.Default.BaitKey2             = txtBaitKey2.Text;
            Properties.Settings.Default.BaitKey3             = txtBaitKey3.Text;
            Properties.Settings.Default.BaitKey4             = txtBaitKey4.Text;
            Properties.Settings.Default.BaitKey5             = txtBaitKey5.Text;
            Properties.Settings.Default.BaitKey6             = txtBaitKey6.Text;
            Properties.Settings.Default.BaitKey7             = txtBaitKey7.Text;
            Properties.Settings.Default.AutoBait             = cbAutoBait.Checked;
            Properties.Settings.Default.CycleThroughBaitList = cbCycleThroughBaitList.Checked;

            SaveHotKeys();

            //Times
            Properties.Settings.Default.LureTime   = int.Parse(txtLureTime.Text);
            Properties.Settings.Default.HearthTime = int.Parse(txtHearthTime.Text);
            Properties.Settings.Default.RaftTime   = int.Parse(txtRaftTime.Text);
            Properties.Settings.Default.CharmTime  = int.Parse(txtCharmTime.Text);
            Properties.Settings.Default.BaitTime   = int.Parse(txtBaitTime.Text);

            /// Anti Afk
            Properties.Settings.Default.AntiAfk      = cbAntiAfk.Checked;
            Properties.Settings.Default.AntiAfkTime  = int.Parse(txtAntiAfkTimer.Text);
            Properties.Settings.Default.AntiAfkMoves = cmbMovements.SelectedIndex;

            /// Language
            Properties.Settings.Default.Txt2speech = chkTxt2speech.Checked;
            if ((string)cmbLanguage.SelectedItem != Properties.Settings.Default.Language)
            {
                Properties.Settings.Default.Language = (string)cmbLanguage.SelectedItem;
                Properties.Settings.Default.Save();

                MessageBox.Show(Translate.GetTranslate("frmSettings", "LABEL_LANGUAGE_CHANGE"),
                                Translate.GetTranslate("frmSettings", "TITLE_LANGUAGE_CHANGE"));

                Thread.Sleep(1000);
                Application.Restart();
            }
            else
            {
                Properties.Settings.Default.Save();
                this.Close();
            }
        }
예제 #35
0
        private void cmbProtocol_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ContentControl protocol = (cmbProtocol.SelectedItem as ContentControl);
            int?           protType;

            if (protocol == null)
            {
                protType = ParseProtocol(cmbProtocol.Text);
            }
            else
            {
                protType = (int)protocol.Tag;
            }

            if (curProtocol == protType)
            {
                return;
            }
            curProtocol = protType;
            if (curProtocol == null)
            {
                return;
            }

            if (protType == (int)FirewallRule.KnownProtocols.TCP || protType == (int)FirewallRule.KnownProtocols.UDP)
            {
                tabParams.SelectedItem = tabPorts;
            }
            else if (protType == (int)FirewallRule.KnownProtocols.ICMP || protType == (int)FirewallRule.KnownProtocols.ICMPv6)
            {
                tabParams.SelectedItem = tabICMP;

                cmbICMP.Items.Clear();
                cmbICMP.Items.Add(new ContentControl()
                {
                    Content = Translate.fmt("icmp_all"), Tag = "*"
                });
                bool v6 = (protType == (int)FirewallRule.KnownProtocols.ICMPv6);
                Dictionary <int, string> types = (v6 ? NetFunc.KnownIcmp6Types : NetFunc.KnownIcmp4Types);
                foreach (int type in types.Keys)
                {
                    cmbICMP.Items.Add(new ContentControl()
                    {
                        Content = type.ToString() + ":* (" + types[type] + ")", Tag = type.ToString() + ":*"
                    });
                }
                cmbICMP.Items.Add(new ContentControl()
                {
                    Content = "3:4 (Type 3, Code 4)", Tag = "3:4"
                });                                                                                        // why does windows firewall has this explicitly
                if (!WpfFunc.CmbSelect(cmbICMP, Rule.GetIcmpTypesAndCodes()) && Rule.IcmpTypesAndCodes != null)
                {
                    cmbICMP.Text = Rule.GetIcmpTypesAndCodes();
                }
            }
            else
            {
                tabParams.SelectedItem = tabNone;
            }

            UpdatePorts();
            someThing_Changed(sender, e);
        }
예제 #36
0
    protected void SaveOrUpdateTranslate(string lang, int curObjID, List<KeyValuePair> lstFieldsNameAndTranslation)
    {
        if (!lang.Equals("vi"))
        {
            var fp = new FilterParams()
            {
                ModuleId = 1,
                ObjType = ObjType.Type1,
                ObjID = curObjID,
                //ObjField = "tieude",
                LangID = Language.GetIDByCode(lang)
            };
            for (int i = 0; i < lstFieldsNameAndTranslation.Count; i++)
            {
                fp.ObjField = lstFieldsNameAndTranslation.ElementAt(i).Key;
                var ts = Translate.GetObject(fp);
                if (ts == null)
                    ts = new Translate();
                else ts = DB.Translates.FirstOrDefault(o => o.ID == ts.ID);

                ts.LangID = fp.LangID;
                ts.Type = fp.ObjType;
                ts.ModuleID = fp.ModuleId;
                ts.ModuleItemID = fp.ObjID;
                ts.ModuleItemField = fp.ObjField;
                ts.Translating = lstFieldsNameAndTranslation.ElementAt(i).Value;

                if (ts.ID <= 0)
                {
                    DB.AddToTranslates(ts);
                }

                DB.SaveChanges();
            }
        }
        else return;
    }
예제 #37
0
        private void UpdatePorts()
        {
            cmbRemotePorts.Items.Clear();
            cmbLocalPorts.Items.Clear();

            if (curProtocol == (int)FirewallRule.KnownProtocols.TCP || curProtocol == (int)FirewallRule.KnownProtocols.UDP)
            {
                cmbRemotePorts.Items.Add(new ContentControl()
                {
                    Content = Translate.fmt("port_any"), Tag = "*"
                });
                cmbLocalPorts.Items.Add(new ContentControl()
                {
                    Content = Translate.fmt("port_any"), Tag = "*"
                });

                if (Rule.Direction == FirewallRule.Directions.Outboun)
                {
                    if (curProtocol == (int)FirewallRule.KnownProtocols.TCP)
                    {
                        cmbRemotePorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordIpTlsOut, Tag = FirewallRule.PortKeywordIpTlsOut
                        });
                    }
                }
                else if (Rule.Direction == FirewallRule.Directions.Inbound)
                {
                    if (curProtocol == (int)FirewallRule.KnownProtocols.TCP)
                    {
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordIpTlsIn, Tag = FirewallRule.PortKeywordIpTlsIn
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordRpcEp, Tag = FirewallRule.PortKeywordRpcEp
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordRpc, Tag = FirewallRule.PortKeywordRpc
                        });
                    }
                    else if (curProtocol == (int)FirewallRule.KnownProtocols.UDP)
                    {
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordTeredo, Tag = FirewallRule.PortKeywordTeredo
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordPly2Disc, Tag = FirewallRule.PortKeywordPly2Disc
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordMDns, Tag = FirewallRule.PortKeywordMDns
                        });
                        cmbLocalPorts.Items.Add(new ContentControl()
                        {
                            Content = FirewallRule.PortKeywordDhcp, Tag = FirewallRule.PortKeywordDhcp
                        });
                    }
                }

                //if (!WpfFunc.CmbSelect(cmbRemotePorts, Rule.RemotePorts) && Rule.RemotePorts != null)
                //    cmbRemotePorts.Text = Rule.RemotePorts;
                viewModel.RemotePort = WpfFunc.CmbPick(cmbRemotePorts, FirewallRule.IsEmptyOrStar(Rule.RemotePorts) ? "*" : Rule.RemotePorts);
                if (viewModel.RemotePort == null)
                {
                    viewModel.RemotePortTxt = Rule.RemotePorts;
                }

                //if (!WpfFunc.CmbSelect(cmbLocalPorts, Rule.LocalPorts) && Rule.LocalPorts != null)
                //    cmbLocalPorts.Text = Rule.LocalPorts;
                viewModel.LocalPort = WpfFunc.CmbPick(cmbLocalPorts, FirewallRule.IsEmptyOrStar(Rule.LocalPorts) ? "*" : Rule.LocalPorts);
                if (viewModel.LocalPort == null)
                {
                    viewModel.LocalPortTxt = Rule.LocalPorts;
                }
            }
        }
 protected void _SetStatusbar(string text = null)
 {
     StatBarText.Text = (text != null) ? text : Translate._("MainWindow.Statusbar.Ready");
     StatBarText.Refresh();
 }
예제 #39
0
        public NotificationWnd()
        {
            InitializeComponent();

            this.Title                      = Translate.fmt("wnd_notify");
            this.btnPrev.Content            = Translate.fmt("lbl_prev");
            this.btnNext.Content            = Translate.fmt("lbl_next");
            this.lblRemember.Content        = Translate.fmt("lbl_remember");
            this.btnIgnore.Content          = Translate.fmt("lbl_ignore");
            this.btnApply.Content           = Translate.fmt("lbl_apply");
            this.consGrid.Columns[0].Header = Translate.fmt("lbl_protocol");
            this.consGrid.Columns[1].Header = Translate.fmt("lbl_ip_port");
            this.consGrid.Columns[2].Header = Translate.fmt("lbl_time_stamp");

            this.Topmost = true;

            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_none"), Tag = Program.Config.AccessLevels.Unconfigured
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_silence"), Tag = Program.Config.AccessLevels.StopNotify
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_allow"), Tag = Program.Config.AccessLevels.FullAccess
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_edit"), Tag = Program.Config.AccessLevels.CustomConfig
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_lan"), Tag = Program.Config.AccessLevels.LocalOnly
            });
            cmbAccess.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("acl_block"), Tag = Program.Config.AccessLevels.BlockAccess
            });
            foreach (ComboBoxItem item in cmbAccess.Items)
            {
                item.Background = ProgramControl.GetAccessColor((Program.Config.AccessLevels)item.Tag);
            }

            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_permanent"), Tag = 0
            });
#if DEBUG
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "1 min"), Tag = 60
            });
#endif
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "5 min"), Tag = 5 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "15 min"), Tag = 15 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "1 h"), Tag = 60 * 60
            });
            cmbRemember.Items.Add(new ComboBoxItem()
            {
                Content = Translate.fmt("lbl_temp", "24 h"), Tag = 24 * 60 * 60
            });
            cmbRemember.SelectedIndex = 0;

            WpfFunc.LoadWnd(this, "Notify");
        }
        private async void _LoadGamefile(string filename)
        {
            if (!_CloseGamefile())
            {
                return;
            }

            if (!File.Exists(filename))
            {
                Log.Info("Tried to load a file which didn't exist anymore!");
                return;
            }

            // Setup savegame
            CurrFile = new Savegame.Savegame(filename);

            // Activate features as configured by user
            CurrFile.EnableDeepAnalysis(Config.Root.deep_analysis.enabled);

            // Peek header first, to ensure the savegame version is fully supported
            Header header = CurrFile.PeekHeader();

            if (header == null)
            {
                Log.Error("Failed to peek header");
                MessageBox.Show(string.Format(Translate._("MainWindow.LoadGamefile.PeekHeader.Failed"), filename),
                                Translate._("MainWindow.Title"), MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }
            if (header.GetVersionEntry() == null)
            {
                // Log this version info in case tool crashes
                Log.Warning("Save is newer than this tool supports: Build={0}, SaveVersion={1}, SaveType={2}",
                            header.GetBuildVersion(), header.SaveVersion, header.Type);
                string save_version = string.Format("Build {0}", header.GetBuildVersion());
                var    ret          = MessageBox.Show(string.Format(Translate._("MainWindow.LoadGamefile.PeekHeader.Warn"), save_version),
                                                      Translate._("MainWindow.Title"), MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (ret == MessageBoxResult.No)
                {
                    return;
                }
            }

            _BlockUI(true);
            _SetStatusbar(string.Format(Translate._("MainWindow.LoadGamefile.Progress.Statusbar"), filename));
            ProgressDialog progress = new ProgressDialog(this, Translate._("MainWindow.LoadGamefile.Progress.Title"));

            try
            {
                await Task.Run(() => {
                    DateTime start_time = DateTime.Now;

                    Log.Info("Loading file '{0}'", filename);
                    progress.CounterFormat = Translate._("MainWindow.LoadGamefile.Progress.CounterFormat");
                    progress.Interval      = 1024 * 1024;             //1024 * 128;
                    CurrFile.Load(progress.Events);
                    //throw new UnknownPropertyException("Hard failure :D", "WTFProperty", 0x10001L);
                    Log.Info("Finished loading");
                    Log.Info("... loaded a total of {0} elements", CurrFile.TotalElements);

                    Log.Info("Creating trees ...");
                    //progress.CounterFormat = Translate._("MainWindow.LoadGamefile.Progress.CounterFormat.2");
                    progress.Interval = 1000;
                    //TreeView.CreateTree(progress.Events);
                    TreeView.CreateTrees(progress.Events);
                    Log.Info("... finished creating trees");

                    DateTime end_time = DateTime.Now;
                    TimeSpan ofs      = end_time - start_time;
                    Log.Info("Loading took {0}", ofs);
                });
            }
            catch (UnknownPropertyException exc)
            {
                CurrFile = null;

                IncidentReportDialog.Show(filename, exc);
            }
            catch (Reader.ReadException exc)
            {
                CurrFile = null;

                IncidentReportDialog.Show(filename, exc);
            }
            finally
            {
                progress = null;
                _SetStatusbar();
                _BlockUI(false);

                _UpdateUIState();
            }
        }
예제 #41
0
 private void btnSetScanArea_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(Translate.GetTranslate("frmSettings", "SCAN_MESSAGE"), Translate.GetTranslate("frmSettings", "SCAN_TITLE"), MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         frmOverlay.GetForm(this).Show();
     }
 }
        private async void _RunUpdateChecker(bool background_check)
        {
            // Do update check, with or without a progress dialog
            ProgressDialog progress = null;

            if (!background_check)
            {
                progress = new ProgressDialog(this, " ");
                progress.CounterFormat = "";
                progress.Interval      = 0;
                progress.Events.Start(-1, Translate._("MainWindow.UpdateCheck.Progress.Title"), " ");
            }

            string        changelog = null;
            Task <string> check     = Task.Run(() => {
                string vers_url = string.Format("{0}?u={1}&v={2}",
                                                Helpers.Unpack("yygpKSi20tc3STNKsUw008vPy8nMS9UtTi0qSy3SS87JL03RL8vxM0jzjAop8IhMTDL2MPDITc/QB0oXZ+bn6WbmpeXrVeTmAAA="),
                                                Settings.USER_KEY, Settings.APPVERSION.Replace(" ", "_"));
                UpdateChecker checker = new UpdateChecker(vers_url, progress != null? progress.Events : null, Logger.LOG);
                string url            = checker.Check(Settings.APPTITLE, Settings.APPVERSION, out changelog);
                checker.Close();
                checker = null;
                return(url);
            });
            await  check;
            string dl_url = check.Result;

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

            if (string.IsNullOrEmpty(dl_url))
            {
                if (!background_check)
                {
                    MessageBox.Show(Translate._("MainWindow.UpdateCheck.NoUpdateAvail"), Translate._("MainWindow.UpdateCheck.Title"));
                }
                return;
            }

            // Prompt user to continue installation
            bool update = false;

            if (string.IsNullOrEmpty(changelog))
            {
                var ret = MessageBox.Show(Translate._("MainWindow.UpdateCheck.NewVersionAvail"),
                                          Translate._("MainWindow.UpdateCheck.Title"), MessageBoxButton.YesNo, MessageBoxImage.Question);
                update = (ret == MessageBoxResult.Yes);
            }
            else
            {
                string[] buttons = new string[] { Translate._("Yes"), Translate._("No"),
                                                  Translate._("MainWindow.UpdateCheck.NewVersionAvail") };
                update = ShowHtmlResDialog.Show(Translate._("MainWindow.UpdateCheck.Title"), changelog, buttons);
            }
            if (!update)
            {
                return;
            }

            // Download installer package, ...
            string dest_file = Path.Combine(Settings.APPPATH, Path.GetFileName(dl_url));

            using (Stream strm = File.Create(dest_file))
            {
                Downloader dl = new Downloader(dl_url, null, Logger.LOG);
                if (!dl.Download(strm))
                {
                    MessageBox.Show(Translate._("MainWindow.UpdateCheck.DownloadFailed"), Translate._("MainWindow.UpdateCheck.Title"));
                    return;
                }
            }
            // ..., and start installer in silent mode (installer will wait until program has closed)
            ProcessStartInfo info = new ProcessStartInfo()
            {
                FileName         = dest_file,
                Arguments        = "/S",
                WorkingDirectory = Settings.APPPATH,
                UseShellExecute  = false,
                ErrorDialog      = false,
            };
            Process process = Process.Start(info);

            if (process == null || process.HasExited)
            {
                MessageBox.Show(Translate._("MainWindow.UpdateCheck.InstallFailed"), Translate._("MainWindow.UpdateCheck.Title"));
                if (process != null)
                {
                    process.Dispose();
                }
                return;
            }

            // End program and let installer do its job
            Close();
        }
예제 #43
0
        private void frmSettings_Load(object sender, EventArgs e)
        {
            /*
             * Set Text from translate file
             */

            this.Text = Translate.GetTranslate("frmSettings", "TITLE");

            tabSettings.TabPages[(int)TabulationIndex.GeneralFishing].Text = Translate.GetTranslate("frmSettings", "TAB_TITLE_GENERAL_FISHING");
            tabSettings.TabPages[(int)TabulationIndex.FindCursor].Text     = Translate.GetTranslate("frmSettings", "TAB_TITLE_FIND_CURSOR");
            tabSettings.TabPages[(int)TabulationIndex.HearingFishing].Text = Translate.GetTranslate("frmSettings", "TAB_TITLE_HEARING_FISH");
            tabSettings.TabPages[(int)TabulationIndex.Premium].Text        = Translate.GetTranslate("frmSettings", "TAB_TITLE_PREMIUM");
            tabSettings.TabPages[(int)TabulationIndex.AntiAfk].Text        = Translate.GetTranslate("frmSettings", "TAB_TITLE_ANTI_AFK");
            tabSettings.TabPages[(int)TabulationIndex.Language].Text       = Translate.GetTranslate("frmSettings", "TAB_TITLE_LANGUAGE");

            /// General

            LabelDelayCast.Text     = Translate.GetTranslate("frmSettings", "LABEL_DELAY_AFTER_CAST");
            LabelDelayCastDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_DELAY_AFTER_CAST_DESC");

            LabelFishWait.Text     = Translate.GetTranslate("frmSettings", "LABEL_FISH_WAIT_LIMIT");
            LabelFishWaitDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_FISH_WAIT_LIMIT_DESC");

            LabelDelayLooting.Text     = Translate.GetTranslate("frmSettings", "LABEL_DELAY_AFTER_LOOTING");
            LabelDelayLootingDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_DELAY_AFTER_LOOTING_DESC");

            /// Finding the Cursor

            LabelScanningSteps.Text     = Translate.GetTranslate("frmSettings", "LABEL_SCANNING_STEPS");
            LabelScanningStepsDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_SCANNING_STEPS_DESC");

            LabelScanningDelay.Text     = Translate.GetTranslate("frmSettings", "LABEL_SCANNING_DELAY");
            LabelScanningDelayDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_SCANNING_DELAY_DESC");

            LabelScanningRetries.Text     = Translate.GetTranslate("frmSettings", "LABEL_SCANNING_RETRIES");
            LabelScanningRetriesDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_SCANNING_RETRIES_DESC");

            cmbCompareIcon.Text       = Translate.GetTranslate("frmSettings", "LABEL_CHECK_ICON");
            LabelCheckCursorIcon.Text = Translate.GetTranslate("frmSettings", "LABEL_CHECK_ICON_DESC");

            cmbAlternativeRoute.Text   = Translate.GetTranslate("frmSettings", "LABEL_ALTERNATIVE_ROUTE");
            LabelAlternativeRoute.Text = Translate.GetTranslate("frmSettings", "LABEL_ALTERNATIVE_ROUTE_DESC");

            LabelScanArea.Text  = Translate.GetTranslate("frmSettings", "LABEL_SCAN_AREA");
            btnSetScanArea.Text = Translate.GetTranslate("frmSettings", "SET_SCANNING_AREA");
            LabelMinXY.Text     = Translate.GetTranslate("frmSettings", "START_XY");
            LabelMaxXY.Text     = Translate.GetTranslate("frmSettings", "END_XY");

            /// Hearing the Fish

            LabelSplashThreshold.Text     = Translate.GetTranslate("frmSettings", "LABEL_SPLASH_THRESHOLD");
            LabelSplashThresholdDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_SPLASH_THRESHOLD_DESC");

            LabelAudioDevice.Text     = Translate.GetTranslate("frmSettings", "LABEL_AUDIO_DEVICE");
            LabelAudioDeviceDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_AUDIO_DEVICE_DESC");

            cbSoundAvg.Text = Translate.GetTranslate("frmSettings", "CB_AVG_SND");

            /// Premium Settings

            LabelCastKey.Text   = Translate.GetTranslate("frmSettings", "LABEL_CAST_KEY");
            LabelLureKey.Text   = Translate.GetTranslate("frmSettings", "LABEL_LURE_KEY");
            LabelHearthKey.Text = Translate.GetTranslate("frmSettings", "LABEL_HEARTHSTONE_KEY");
            LabelRaftKey.Text   = Translate.GetTranslate("frmSettings", "LABEL_RAFT_KEY");
            LabelCharmKey.Text  = Translate.GetTranslate("frmSettings", "LABEL_CHARM_KEY");
            LabelBaitKey1.Text  = Translate.GetTranslate("frmSettings", "LABEL_BAIT_KEY_1");
            LabelBaitKey2.Text  = Translate.GetTranslate("frmSettings", "LABEL_BAIT_KEY_2");
            LabelBaitKey3.Text  = Translate.GetTranslate("frmSettings", "LABEL_BAIT_KEY_3");
            LabelBaitKey4.Text  = Translate.GetTranslate("frmSettings", "LABEL_BAIT_KEY_4");
            LabelBaitKey5.Text  = Translate.GetTranslate("frmSettings", "LABEL_BAIT_KEY_5");
            LabelBaitKey6.Text  = Translate.GetTranslate("frmSettings", "LABEL_BAIT_KEY_6");
            LabelBaitKey7.Text  = Translate.GetTranslate("frmSettings", "LABEL_BAIT_KEY_7");

            LoadHotKeys();

            LabelCustomizeDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_CUSTOMIZE_DESC");

            cbAlt.Text                  = Translate.GetTranslate("frmSettings", "CB_ALT_KEY");
            cbAutoLure.Text             = Translate.GetTranslate("frmSettings", "CB_AUTO_LURE");
            cbHearth.Text               = Translate.GetTranslate("frmSettings", "CB_AUTO_HEARTHSTONE");
            cbApplyRaft.Text            = Translate.GetTranslate("frmSettings", "CB_AUTO_RAFT");
            cbApplyCharm.Text           = Translate.GetTranslate("frmSettings", "CB_AUTO_CHARM");
            cbAutoBait.Text             = Translate.GetTranslate("frmSettings", "CB_AUTO_BAIT");
            cbCycleThroughBaitList.Text = Translate.GetTranslate("frmSettings", "CB_CYCLE_THROUGH_BAIT_LIST");
            cbShiftLoot.Text            = Translate.GetTranslate("frmSettings", "CB_SHIFT_LOOT");

            LabelProcessName.Text     = Translate.GetTranslate("frmSettings", "LABEL_PROCESS_NAME");
            LabelProcessNameDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_PROCESS_NAME_DESC");

            /// Anti Afk

            LoadAntiAfkMovements();
            cbAntiAfk.Text = Translate.GetTranslate("frmSettings", "CB_ANTI_AFK");

            /// Language Settings

            labelLanguage.Text     = Translate.GetTranslate("frmSettings", "LABEL_LANGUAGE");
            labelLanguageDesc.Text = Translate.GetTranslate("frmSettings", "LABEL_LANGUAGE_DESC");

            /// Buttons

            buttonSave.Text   = Translate.GetTranslate("frmSettings", "BUTTON_SAVE");
            buttonCancel.Text = Translate.GetTranslate("frmSettings", "BUTTON_CANCEL");

            /*
             * Set Settings from save
             */

            /// General
            txtCastDelay.Text    = Properties.Settings.Default.CastingDelay.ToString();
            txtLootingDelay.Text = Properties.Settings.Default.LootingDelay.ToString();
            txtFishWait.Text     = Properties.Settings.Default.FishWait.ToString();

            /// Finding the Cursor
            txtDelay.Text               = Properties.Settings.Default.ScanningDelay.ToString();
            txtRetries.Text             = Properties.Settings.Default.ScanningRetries.ToString();
            txtScanSteps.Text           = Properties.Settings.Default.ScanningSteps.ToString();
            cmbCompareIcon.Checked      = Properties.Settings.Default.CheckCursor;
            cmbAlternativeRoute.Checked = Properties.Settings.Default.AlternativeRoute;
            customAreaCheckbox.Checked  = Properties.Settings.Default.customScanArea;
            txtMinXY.Text               = Properties.Settings.Default.minScanXY.ToString();
            txtMaxXY.Text               = Properties.Settings.Default.maxScanXY.ToString();

            /// Hearing the Fish
            txtSplash.Text = Properties.Settings.Default.SplashLimit.ToString();
            LoadAudioDevices();
            cbSoundAvg.Checked = Properties.Settings.Default.AverageSound;

            /// Premium Settings
            txtProcName.Text   = Properties.Settings.Default.ProcName;
            cbAutoLure.Checked = Properties.Settings.Default.AutoLure;
            cbHearth.Checked   = Properties.Settings.Default.SwapGear;
            cbAlt.Checked      = Properties.Settings.Default.UseAltKey;

            txtFishKey.Text    = Properties.Settings.Default.FishKey;
            txtLureKey.Text    = Properties.Settings.Default.LureKey;
            txtHearthKey.Text  = Properties.Settings.Default.HearthKey;
            cbHearth.Checked   = Properties.Settings.Default.AutoHearth;
            txtHearthTime.Text = Properties.Settings.Default.HearthTime.ToString();

            // MoP Premium (Angler's Raft & Ancient Pandaren Fishing Charm)
            txtCharmKey.Text     = Properties.Settings.Default.CharmKey;
            txtRaftKey.Text      = Properties.Settings.Default.RaftKey;
            cbApplyRaft.Checked  = Properties.Settings.Default.AutoRaft;
            cbApplyCharm.Checked = Properties.Settings.Default.AutoCharm;
            cbShiftLoot.Checked  = Properties.Settings.Default.ShiftLoot;

            // WoD Premium (Bait)
            txtBaitKey1.Text               = Properties.Settings.Default.BaitKey1;
            txtBaitKey2.Text               = Properties.Settings.Default.BaitKey2;
            txtBaitKey3.Text               = Properties.Settings.Default.BaitKey3;
            txtBaitKey4.Text               = Properties.Settings.Default.BaitKey4;
            txtBaitKey5.Text               = Properties.Settings.Default.BaitKey5;
            txtBaitKey6.Text               = Properties.Settings.Default.BaitKey6;
            txtBaitKey7.Text               = Properties.Settings.Default.BaitKey7;
            cbAutoBait.Checked             = Properties.Settings.Default.AutoBait;
            cbCycleThroughBaitList.Checked = Properties.Settings.Default.CycleThroughBaitList;

            //Times
            txtLureTime.Text   = Properties.Settings.Default.LureTime.ToString();
            txtHearthTime.Text = Properties.Settings.Default.HearthTime.ToString();
            txtRaftTime.Text   = Properties.Settings.Default.RaftTime.ToString();
            txtCharmTime.Text  = Properties.Settings.Default.CharmTime.ToString();
            txtBaitTime.Text   = Properties.Settings.Default.BaitTime.ToString();

            /// Anti Afk
            cbAntiAfk.Checked          = Properties.Settings.Default.AntiAfk;
            txtAntiAfkTimer.Text       = Properties.Settings.Default.AntiAfkTime.ToString();
            cmbMovements.SelectedIndex = Properties.Settings.Default.AntiAfkMoves;

            /// Languages
            chkTxt2speech.Checked = Properties.Settings.Default.Txt2speech;
            LoadLanguages();
        }
예제 #44
0
 /// <summary>
 /// 转繁体中文
 /// </summary>
 /// <param name="text"></param>
 /// <param name="type">0、繁体中文,1、港澳繁体,2、台湾正体 </param>
 /// <returns></returns>
 public static string ToTraditionalChinese(string text, int type = 0)
 {
     return(Translate.ToTraditionalChinese(text, type));
 }
예제 #45
0
        public void UpdateInfo()
        {
            mainListView.Items.Clear();

            if ((parent.mcagent != null) && (parent.currentAgentName != null) && (parent.currentAgentName.Equals("~")))
            {
                if ((parent.mcagent.DesktopSessions != null) && (parent.mcagent.DesktopSessions.Count > 0))
                {
                    foreach (string user in parent.mcagent.DesktopSessions.Keys)
                    {
                        mainListView.Items.Add(new ListViewItem(new string[3] {
                            getUserName(user), Translate.T(Properties.Resources.Desktop), parent.mcagent.DesktopSessions[user].ToString()
                        }));
                    }
                }
                if ((parent.mcagent.TerminalSessions != null) && (parent.mcagent.TerminalSessions.Count > 0))
                {
                    foreach (string user in parent.mcagent.TerminalSessions.Keys)
                    {
                        mainListView.Items.Add(new ListViewItem(new string[3] {
                            getUserName(user), Translate.T(Properties.Resources.Terminal), parent.mcagent.TerminalSessions[user].ToString()
                        }));
                    }
                }
                if ((parent.mcagent.FilesSessions != null) && (parent.mcagent.FilesSessions.Count > 0))
                {
                    foreach (string user in parent.mcagent.FilesSessions.Keys)
                    {
                        mainListView.Items.Add(new ListViewItem(new string[3] {
                            getUserName(user), Translate.T(Properties.Resources.Files), parent.mcagent.FilesSessions[user].ToString()
                        }));
                    }
                }
                if ((parent.mcagent.TcpSessions != null) && (parent.mcagent.TcpSessions.Count > 0))
                {
                    foreach (string user in parent.mcagent.TcpSessions.Keys)
                    {
                        mainListView.Items.Add(new ListViewItem(new string[3] {
                            getUserName(user), Translate.T(Properties.Resources.TCPrelay), parent.mcagent.TcpSessions[user].ToString()
                        }));
                    }
                }
                if ((parent.mcagent.UdpSessions != null) && (parent.mcagent.UdpSessions.Count > 0))
                {
                    foreach (string user in parent.mcagent.UdpSessions.Keys)
                    {
                        mainListView.Items.Add(new ListViewItem(new string[3] {
                            getUserName(user), Translate.T(Properties.Resources.UDPrelay), parent.mcagent.UdpSessions[user].ToString()
                        }));
                    }
                }
            }
            else if (parent.agent != null)
            {
                if ((parent.agent.DesktopSessions != null) && (parent.agent.DesktopSessions.Count > 0))
                {
                    foreach (string user in parent.agent.DesktopSessions.Keys)
                    {
                        mainListView.Items.Add(new ListViewItem(new string[3] {
                            getUserName2(user), Translate.T(Properties.Resources.Desktop), parent.agent.DesktopSessions[user].ToString()
                        }));
                    }
                }
                if ((parent.agent.TerminalSessions != null) && (parent.agent.TerminalSessions.Count > 0))
                {
                    foreach (string user in parent.agent.TerminalSessions.Keys)
                    {
                        mainListView.Items.Add(new ListViewItem(new string[3] {
                            getUserName2(user), Translate.T(Properties.Resources.Terminal), parent.agent.TerminalSessions[user].ToString()
                        }));
                    }
                }
                if ((parent.agent.FilesSessions != null) && (parent.agent.FilesSessions.Count > 0))
                {
                    foreach (string user in parent.agent.FilesSessions.Keys)
                    {
                        mainListView.Items.Add(new ListViewItem(new string[3] {
                            getUserName2(user), Translate.T(Properties.Resources.Files), parent.agent.FilesSessions[user].ToString()
                        }));
                    }
                }
                if ((parent.agent.TcpSessions != null) && (parent.agent.TcpSessions.Count > 0))
                {
                    foreach (string user in parent.agent.TcpSessions.Keys)
                    {
                        mainListView.Items.Add(new ListViewItem(new string[3] {
                            getUserName2(user), Translate.T(Properties.Resources.TCPrelay), parent.agent.TcpSessions[user].ToString()
                        }));
                    }
                }
                if ((parent.agent.UdpSessions != null) && (parent.agent.UdpSessions.Count > 0))
                {
                    foreach (string user in parent.agent.UdpSessions.Keys)
                    {
                        mainListView.Items.Add(new ListViewItem(new string[3] {
                            getUserName2(user), Translate.T(Properties.Resources.UDPrelay), parent.agent.UdpSessions[user].ToString()
                        }));
                    }
                }
            }

            if (mainListView.Items.Count == 0)
            {
                mainListView.Items.Add(new ListViewItem(new string[3] {
                    Translate.T(Properties.Resources.PNoneP), "", ""
                }));
            }
        }
예제 #46
0
 /// <summary>
 /// 转简体中文
 /// </summary>
 /// <param name="text"></param>
 /// <param name="srcType">0、繁体中文,1、港澳繁体,2、台湾正体</param>
 /// <returns></returns>
 public static string ToSimplifiedChinese(string text, int srcType = 0)
 {
     return(Translate.ToSimplifiedChinese(text, srcType));
 }
예제 #47
0
        public void ActionCE(ControlElement ce, PointF from, PointF to)
        {
            var rect = GetRect();

            switch (ce)
            {
            case ControlElement.Inside:
                Translate = Translate.Move(to.Shift(from));
                break;

            case ControlElement.Outside:
                var c   = PosCE(ControlElement.Center);
                var a   = from.Shift(c);
                var b   = to.Shift(c);
                var nA  = a.Norm();
                var nB  = b.Norm();
                var d   = from.DistanceTo(to);
                var cos = (nA * nA + nB * nB - d * d) / (2 * nA * nB);                         // law of cosines
                var ang = Math.Acos(cos) * Math.Sign(a.Cross(b));
                Rotate += ang.ToDegrees();
                Rotate %= 360;
                break;

            case ControlElement.Center:
                RotateCenter = RotateCenter.Move(to.Shift(from).Relative(img.Size));
                break;

            case ControlElement.SizeTopLeft:
                Scale     = Scale.Move(to.Shift(from).Factors(-1, -1).Relative(img.Size));
                Translate = Translate.Move(to.Shift(from).Factors(1, 1));
                break;

            case ControlElement.SizeTopRight:
                Scale     = Scale.Move(to.Shift(from).Factors(1, -1).Relative(img.Size));
                Translate = Translate.Move(to.Shift(from).Factors(0, 1));
                break;

            case ControlElement.SizeBottomRight:
                Scale = Scale.Move(to.Shift(from).Relative(img.Size));
                break;

            case ControlElement.SizeBottomLeft:
                Scale     = Scale.Move(to.Shift(from).Factors(-1, 1).Relative(img.Size));
                Translate = Translate.Move(to.Shift(from).Factors(1, 0));
                break;

            case ControlElement.SizeTop:
                Scale     = Scale.Move(to.Shift(from).Factors(0, -1).Relative(img.Size));
                Translate = Translate.Move(to.Shift(from).Factors(0, 1));
                break;

            case ControlElement.SizeRight:
                Scale = Scale.Move(to.Shift(from).Factors(1, 0).Relative(img.Size));
                break;

            case ControlElement.SizeBottom:
                Scale = Scale.Move(to.Shift(from).Factors(0, 1).Relative(img.Size));
                break;

            case ControlElement.SizeLeft:
                Scale     = Scale.Move(to.Shift(from).Factors(-1, 0).Relative(img.Size));
                Translate = Translate.Move(to.Shift(from).Factors(1, 0));
                break;

            default:
                break;
            }
            if (Math.Abs(Scale.X) < 0.0001)
            {
                Scale = new PointF(0.0001f, Scale.Y);
            }
            if (Math.Abs(Scale.Y) < 0.0001)
            {
                Scale = new PointF(Scale.X, 0.0001f);
            }
        }
예제 #48
0
 /// <summary>
 /// 清理 简繁转换 缓存
 /// </summary>
 public static void ClearTranslate()
 {
     Translate.ClearTranslate();
 }
        protected virtual string GetMatchingPatternLabel(VisitorDataSet.ProfilesRow profile, Database database)
        {
            var builder     = new StringBuilder();
            var patternItem = (PatternCardItem)GetPatternItem(profile, database);

            if (patternItem != null)
            {
                builder.Append("<div style='padding-bottom:5px;'>");
                //builder.AppendFormat("<span style='margin-left:10px; margin-right:10px;'>{0}</span>", GetImage(patternItem.Image.MediaItem));
                builder.AppendFormat("<span style='margin-left:10px; margin-right:10px;'>{0}</span>", GetImage(patternItem.Image));
                builder.AppendFormat("<span style='margin-right:10px; vertical-align:top;'>{0}:</span>", Translate.Text("Matches the pattern"));
                builder.AppendFormat("<span style='vertical-align:top'>{0}</span>", patternItem.Name);
                builder.Append("</div>");
            }
            return(builder.ToString());
        }
예제 #50
0
        /// <summary>
        /// 英語から日本語へ翻訳
        /// </summary>
        /// <param name="TranslateText"></param>
        public void Translate( string directoryName ,
                               string cfgFilename ,
                               Text.TextData textData ,
                               Translate.TranslateText translateText )
        {

            if ( directoryName.Equals( "" )
                || cfgFilename.Equals( "" )
                || translateText.SourceText.Equals( "" ) )
            {
                return;
            }

            //dataOrder
            if ( !this.DataOrder.ContainsKey( directoryName ) )
            {
                this.DataOrder.Add( directoryName , new Dictionary<DataType , int>() );
            }
            if ( !( this.DataOrder[directoryName] ).ContainsKey( textData.DataType ) )
            {
                ( this.DataOrder[directoryName] ).Add( textData.DataType , 1 );
            }
            int dataOrder =  (this.DataOrder[directoryName])[textData.DataType]++;

            try
            {
                //処理対象DB
                DataTable.TranslationDataTable tgtDB = this.TranslationDataTable[textData.DataType];

                //DBに存在するかチェック
                DataRow[] selectRow = tgtDB.GetExistsDataRow(directoryName, textData, translateText);
                if ( selectRow.Length > 0 )
                {
                    //データが存在する

                    DataRow tgtRow = selectRow[0];
                    DataRow sameTextRow = null;

                    //データあり
                    translateText.JapaneseText = ( string ) tgtRow[DataTable.TranslationDataTable.ColumnNameJapaneseText];

                    //存在チェックありに変更
                    tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameExists , true );

                    //Order
                    tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameSortOrder , dataOrder );

                    //変更無しに設定
                    tgtRow.AcceptChanges();





                    //元テキスト変更の場合
                    if ( !translateText.SourceText.Equals( ( string ) tgtRow[DataTable.TranslationDataTable.ColumnNameEnglishText] ) )
                    {
                        //英語テキスト変更
                        tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameEnglishText , translateText.SourceText );
                        tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameMemo , "英語テキスト変更" );

                        //英語テキスト変更のため再翻訳
                        //翻訳済みテキストと同じデータがあればそれを使用する
                        sameTextRow = tgtDB.SearchSameText( translateText.SourceText );
                        if ( sameTextRow != null )
                        {
                            translateText.JapaneseText = ( string ) sameTextRow[DataTable.TranslationDataTable.ColumnNameJapaneseText];

                            //備考
                            tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameMemo , "英語テキスト変更:同じ英語テキストから日本語を取得" );
                            tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameAutoTrans , sameTextRow[DataTable.TranslationDataTable.ColumnNameAutoTrans] );
                        }
                    }
                    else if ( translateText.JapaneseText.Equals( "" ) )
                    {
                        //未翻訳
                        //翻訳済みテキストと同じデータがあればそれを使用する
                        sameTextRow = tgtDB.SearchSameText( translateText.SourceText );
                        if ( sameTextRow != null )
                        {
                            translateText.JapaneseText = ( string ) sameTextRow[DataTable.TranslationDataTable.ColumnNameJapaneseText];

                            //備考
                            tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameMemo , "同じ英語テキストから日本語を取得" );
                            tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameAutoTrans , sameTextRow[DataTable.TranslationDataTable.ColumnNameAutoTrans] );
                        }
                    }
                    else if ( tgtRow[DataTable.TranslationDataTable.ColumnNameAutoTrans].Equals( true ) )
                    {
                        //自動翻訳の場合で、英語データが同じで手動翻訳の場合はそちらを使用する
                        sameTextRow = tgtDB.SearchSameText( translateText.SourceText );
                        if ( sameTextRow != null && sameTextRow[DataTable.TranslationDataTable.ColumnNameAutoTrans].Equals( false ) )
                        {
                            translateText.JapaneseText = ( string ) sameTextRow[DataTable.TranslationDataTable.ColumnNameJapaneseText];

                            //備考
                            tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameMemo , "同じ英語テキストから日本語を取得" );
                            tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameAutoTrans , sameTextRow[DataTable.TranslationDataTable.ColumnNameAutoTrans] );
                        }
                    }


                    //空欄の場合や元テキストが変更され、同じ翻訳データが無い場合は再翻訳
                    if ( translateText.JapaneseText.Equals( "" ) && this.TranslatorApi != null )
                    {
                        //自動翻訳
                        translateText.JapaneseText = this.ProperNoun.ReinstateDummyText(
                                                                    this.TranslatorApi.TranslateEnglishToJapanese(
                                                                            this.ProperNoun.ReplaceDummyText( directoryName , translateText.SourceText , textData.DataType )
                                                                                    )
                                                                                 );
                        if ( !translateText.JapaneseText.Equals( "" ) )
                        {
                            tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameMemo , "自動翻訳で日本語を取得" );
                            tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameAutoTrans , true );
                        }
                    }

                    //日本語が変更されていたらデータ保存
                    tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameJapaneseText , translateText.JapaneseText );

                    //タイトル等データをセット
                    tgtDB.SetTitleData( tgtRow , textData , translateText );


                    if ( tgtRow.RowState != DataRowState.Unchanged )
                    {
                        //変更された
                        // 更新日
                        tgtDB.SetDataValue( tgtRow , DataTable.TranslationDataTable.ColumnNameUpdateDate , System.DateTime.Now.ToString( "yyyy-MM-dd HH:mm:ss" ) );
                    }

                    //コメント設定
                    translateText.Comment = String.Format( "{0} {1}" ,
                        tgtRow[DataTable.TranslationDataTable.ColumnNameUpdateDate] ,
                        tgtRow[DataTable.TranslationDataTable.ColumnNameMemo] );


                }
                else
                {
                    //データ無し

                    //新規レコード追加
                    //新規行
                    DataRow newRow = tgtDB.NewRow();
                    DataRow sameTextRow = null;

                    // 備考
                    tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameMemo , "新規追加" );

                    //翻訳済みで英語テキストが同じデータがあればそれを使用する
                    sameTextRow = tgtDB.SearchSameText( translateText.SourceText );
                    if ( sameTextRow != null )
                    {
                        translateText.JapaneseText = ( string ) sameTextRow[DataTable.TranslationDataTable.ColumnNameJapaneseText];

                        tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameMemo , "新規追加:同じ英語テキストから日本語を取得" );
                        tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameAutoTrans , sameTextRow[DataTable.TranslationDataTable.ColumnNameAutoTrans] );
                    }
                    else
                    {
                        //データ無しの場合は自動翻訳
                        if ( translateText.JapaneseText.Equals( "" ) && this.TranslatorApi != null )
                        {
                            //自動翻訳
                            translateText.JapaneseText = this.ProperNoun.ReinstateDummyText(
                                                                        this.TranslatorApi.TranslateEnglishToJapanese(
                                                                                this.ProperNoun.ReplaceDummyText( directoryName , translateText.SourceText , textData.DataType )
                                                                                        )
                                                                                     );

                            if ( !translateText.JapaneseText.Equals( "" ) )
                            {
                                tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameMemo , "新規追加:自動翻訳で日本語を取得" );
                                tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameAutoTrans , true );
                            }
                        }
                    }

                    //フォルダ名
                    tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameDirName , directoryName );
                    // 元テキスト
                    tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameEnglishText , translateText.SourceText );
                    // 日本語テキスト
                    tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameJapaneseText , translateText.JapaneseText );
                    // cfgファイル名
                    tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameCgfFileName , cfgFilename );

                    // 追加日
                    tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameAddDate , System.DateTime.Now.ToString( "yyyy-MM-dd HH:mm:ss" ) );
                    // 更新日
                    tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameUpdateDate , System.DateTime.Now.ToString( "yyyy-MM-dd HH:mm:ss" ) );

                    //Order
                    tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameSortOrder , dataOrder );

                    //存在チェック
                    tgtDB.SetDataValue( newRow , DataTable.TranslationDataTable.ColumnNameExists , true );

                    //タイトル等データをセット
                    tgtDB.SetTitleData( newRow , textData , translateText );

                    //新規追加
                    tgtDB.Rows.Add( newRow );

                    //コメント設定
                    translateText.Comment = String.Format( "{0} {1}" ,
                        newRow[DataTable.TranslationDataTable.ColumnNameUpdateDate] ,
                        newRow[DataTable.TranslationDataTable.ColumnNameMemo] );
                }


            }
            catch
            {
                throw;
            }


        }