Пример #1
0
 private void lbSearch_MouseHover(object sender, EventArgs e)
 {
     lbSearch.BackColor = ColorTranslator.FromHtml("#2b2b2b");
 }
Пример #2
0
        public override string ToText(Subtitle subtitle, string title)
        {
            const string header =
                @"[Script Info]
; This is a Sub Station Alpha v4 script.
Title: {0}
ScriptType: v4.00
Collisions: Normal
PlayDepth: 0

[V4 Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
Style: Default,{1},{2},{3},65535,65535,-2147483640,-1,0,1,{4},{5},2,10,10,10,0,1

[Events]
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text";

            const string headerNoStyles =
                @"[Script Info]
; This is a Sub Station Alpha v4 script.
Title: {0}
ScriptType: v4.00
Collisions: Normal
PlayDepth: 0

[V4 Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
{1}

[Events]
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text";

            const string timeCodeFormat       = "{0}:{1:00}:{2:00}.{3:00}"; // h:mm:ss.cc
            const string paragraphWriteFormat = "Dialogue: Marked={4},{0},{1},{3},{5},0000,0000,0000,{6},{2}";
            const string commentWriteFormat   = "Comment: Marked={4},{0},{1},{3},{5},0000,0000,0000,{6},{2}";

            var           sb               = new StringBuilder();
            Color         fontColor        = Color.FromArgb(Configuration.Settings.SubtitleSettings.SsaFontColorArgb);
            bool          isValidAssHeader = !string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4 Styles]");
            List <string> styles           = new List <string>();

            if (isValidAssHeader)
            {
                sb.AppendLine(subtitle.Header.Trim());
                const string formatLine = "Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text";
                if (!subtitle.Header.Contains(formatLine))
                {
                    sb.AppendLine(formatLine);
                }
                styles = AdvancedSubStationAlpha.GetStylesFromHeader(subtitle.Header);
            }
            else if (!string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.Contains("[V4+ Styles]"))
            {
                LoadStylesFromAdvancedSubstationAlpha(subtitle, title, subtitle.Header, headerNoStyles, sb);
            }
            else if (subtitle.Header != null && subtitle.Header.Contains("http://www.w3.org/ns/ttml"))
            {
                LoadStylesFromTimedText10(subtitle, title, header, headerNoStyles, sb);
            }
            else
            {
                sb.AppendLine(string.Format(header,
                                            title,
                                            Configuration.Settings.SubtitleSettings.SsaFontName,
                                            (int)Configuration.Settings.SubtitleSettings.SsaFontSize,
                                            ColorTranslator.ToWin32(fontColor),
                                            Configuration.Settings.SubtitleSettings.SsaOutline,
                                            Configuration.Settings.SubtitleSettings.SsaShadow
                                            ));
            }
            foreach (Paragraph p in subtitle.Paragraphs)
            {
                string start = string.Format(timeCodeFormat, p.StartTime.Hours, p.StartTime.Minutes, p.StartTime.Seconds, p.StartTime.Milliseconds / 10);
                string end   = string.Format(timeCodeFormat, p.EndTime.Hours, p.EndTime.Minutes, p.EndTime.Seconds, p.EndTime.Milliseconds / 10);
                string style = "Default";
                string actor = "NTP";
                if (!string.IsNullOrEmpty(p.Actor))
                {
                    actor = p.Actor;
                }
                string effect = "!Effect";
                if (!string.IsNullOrEmpty(p.Effect))
                {
                    effect = p.Effect;
                }
                if (!string.IsNullOrEmpty(p.Extra) && isValidAssHeader && styles.Contains(p.Extra))
                {
                    style = p.Extra;
                }
                if (p.IsComment)
                {
                    sb.AppendLine(string.Format(commentWriteFormat, start, end, AdvancedSubStationAlpha.FormatText(p), style, p.Layer, actor, effect));
                }
                else
                {
                    sb.AppendLine(string.Format(paragraphWriteFormat, start, end, AdvancedSubStationAlpha.FormatText(p), style, p.Layer, actor, effect));
                }
            }
            return(sb.ToString().Trim());
        }
Пример #3
0
        private void AddTextToRichTextBox(RichTextBox rtb, bool bold, bool italic, bool underline, string color, string text)
        {
            if (text.Length > 0)
            {
                int length = rtb.Text.Length;
                richTextBoxPreview.Text += text;

                _colorList.Add(new ColorEntry {
                    Start = length, Length = text.Length, Color = string.IsNullOrWhiteSpace(color) ? Color.White : ColorTranslator.FromHtml(color)
                });

                var fontStyle = new FontStyle();
                if (underline)
                {
                    fontStyle = fontStyle | FontStyle.Underline;
                }
                if (italic)
                {
                    fontStyle = fontStyle | FontStyle.Italic;
                }
                if (bold)
                {
                    fontStyle = fontStyle | FontStyle.Bold;
                }
                _fontList.Add(new FontEntry {
                    Start = length, Length = text.Length, Font = new Font(rtb.Font.FontFamily, rtb.Font.Size, fontStyle)
                });
            }
        }
Пример #4
0
 public static Color RowColor()
 {
     //return Color.LightCyan;
     return(ColorTranslator.FromHtml("#E0F8E0"));
     //return Color.#CEF6CE;
 }
Пример #5
0
    protected void cbpEdit_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
    {
        JsonObjectCollection objs     = new JsonObjectCollection();
        ASPxCallbackPanel    cbp      = (ASPxCallbackPanel)sender;
        int            attributeID    = 0;
        bool           isEffective    = false;
        PartyAttribute partyAttribute = null;

        string[] parameters = e.Parameter.Split(';');
        if (parameters.Length > 1)
        {
            int index = int.Parse(parameters[1]);
            if (index >= 0)
            {
                if (OwnerID != 0)
                {
                    attributeID    = (int)gdvPartyAttribute.GetRowValues(index, gdvPartyAttribute.KeyFieldName);
                    partyAttribute = PartyAttribute.Find(iSabayaContext, attributeID);
                }
                else
                {
                    TreeListNode node = (TreeListNode)gdvPartyAttribute.GetRowValues(index, "AttributeKey");
                    ICategorizedTemporalList <PartyAttribute> attributes = PartyAttributes;
                    for (int i = 0; i < attributes.Count; i++)
                    {
                        if (attributes[i].AttributeKey.NodeID == node.NodeID)
                        {
                            partyAttribute = attributes[i];
                            break;
                        }
                    }
                }
            }
        }
        switch (parameters[0])
        {
        case KEY_DISPLAY:
            tbButtonSaveCancel.Visible = false;
            uplImage.Visible           = false;
            btnUploadImg.Visible       = false;
            if (partyAttribute != null)
            {
                isEffective = partyAttribute.EffectivePeriod.IsEffective();
                if (!isEffective)
                {
                    string color = ColorTranslator.ToHtml(System.Drawing.Color.Red);
                    tdAttributeKey.Style.Add(HtmlTextWriterStyle.Color, color);
                    tdEffectiveTo.Style.Add(HtmlTextWriterStyle.Color, color);
                    tdEffectiveFrom.Style.Add(HtmlTextWriterStyle.Color, color);
                    tdValueDate.Style.Add(HtmlTextWriterStyle.Color, color);
                    tdValueMLS.Style.Add(HtmlTextWriterStyle.Color, color);
                    tdValueNode.Style.Add(HtmlTextWriterStyle.Color, color);
                    tdValueNumber.Style.Add(HtmlTextWriterStyle.Color, color);
                    tdValueText.Style.Add(HtmlTextWriterStyle.Color, color);
                    tdValueImage.Style.Add(HtmlTextWriterStyle.Color, color);
                }
                tdAttributeKey.InnerText  = partyAttribute.AttributeKey.Title.ToString(LanguageCode);
                tdEffectiveTo.InnerText   = partyAttribute.EffectivePeriod.ExpiryDate.ToString(base.DateOutputFormat);
                tdEffectiveFrom.InnerText = partyAttribute.EffectivePeriod.EffectiveDate.ToString(base.DateOutputFormat);
                tdValueDate.InnerText     = partyAttribute.ValueDate.ToString(base.DateOutputFormat);
                tdValueMLS.InnerHtml      = "&nbsp;";
                if (partyAttribute.ValueMLS != null)
                {
                    string value = partyAttribute.ValueMLS.ToString(base.LanguageCode);
                    if (!string.IsNullOrEmpty(value))
                    {
                        tdValueMLS.InnerHtml = partyAttribute.ValueMLS.ToString(base.LanguageCode);
                    }
                }
                tdValueNode.InnerHtml = partyAttribute.ValueNode != null?partyAttribute.ValueNode.ToString(base.LanguageCode) : "&nbsp;";

                tdValueNumber.InnerHtml = partyAttribute.ValueNumber.ToString();
                tdValueText.InnerHtml   = !String.IsNullOrEmpty(partyAttribute.ValueText) ? partyAttribute.ValueText : "&nbsp;";
                if (partyAttribute.ValueImage != null)
                {
                    Size   aspectSize = ImageUtil.GetAspectSize(partyAttribute.ValueImage.Size, 100);
                    byte[] imageBytes = ImageUtil.ImageToBytes(partyAttribute.ValueImage);
                    ctrlValueImage.ContentBytes = imageBytes;
                    ctrlValueImage.Width        = aspectSize.Width;
                    ctrlValueImage.Height       = aspectSize.Height;
                }
                else
                {
                    tdValueImage.InnerHtml = "&nbsp;";
                }
            }
            else
            {
                panelEditForm.Controls.Clear();
                panelEditForm.Controls.Add(new Label()
                {
                    Text = "No Party Attribute"
                });
            }

            break;

        //===============================================================================
        // Edit case is obsoleted
        //===============================================================================
        case KEY_EDIT:
            tbButtonSaveCancel.Visible = true;
            TreeListNode rootNode = null;
            switch (OwnerDiscriminator)
            {
            case 10: rootNode = iSabayaContext.Configuration.Organization.AttributeKeyParentNode; break;   //Organization;

            case 15: rootNode = iSabayaContext.Configuration.Organization.AttributeKeyParentNode; break;   //OrgUnit

            case 20: rootNode = iSabayaContext.Configuration.Person.AttributeKeyParentNode; break;         //Person

            //case 30: rootNode = iSabayaContext.iSabayaConfig.MF.AttributeKeyRootNode; break; //MutualFund
            //case 40: rootNode = iSabayaContext.iSabayaConfig.MF.AttributeKeyRootNode; break; // ProvidentFund
            //case 50: rootNode = iSabayaContext.iSabayaConfig.MF.AttributeKeyRootNode; break; // MFAccount
            //case 60: rootNode = iSabayaContext.iSabayaConfig.MF.AttributeKeyRootNode; break; //Employee
            default: break;
            }
            ctrlAttributeKey.ParentNode = rootNode;
            ctrlAttributeKey.DataBind();
            ctrlAttributeKey.SetValidation("attributeEdit");
            //ctrlAttributeKey.InitializeTreeListNode("Attribute Key", rootNode, null);
            uplImage.Visible     = true;
            btnUploadImg.Visible = true;
            if (gdvPartyAttribute.FocusedRowIndex >= 0)
            {
                if (partyAttribute != null)
                {
                    ctrlAttributeKey.SelectedNode = partyAttribute.AttributeKey;
                    ctrlEffectiveFrom.Date        = partyAttribute.EffectivePeriod.EffectiveDate;
                    ctrlEffectiveTo.Date          = partyAttribute.EffectivePeriod.ExpiryDate;
                    ctrlValueDate.Value           = partyAttribute.ValueDate != null ? (object)partyAttribute.ValueDate : null;
                    ctrlValueMLS.Value            = partyAttribute.ValueMLS;
                    spnValueNumber.Value          = partyAttribute.ValueNumber;
                    txtValueText.Value            = partyAttribute.ValueText;
                    if (partyAttribute.ValueImage != null)
                    {
                        Size   aspectSize = ImageUtil.GetAspectSize(partyAttribute.ValueImage.Size, 100);
                        byte[] imageBytes = ImageUtil.ImageToBytes(partyAttribute.ValueImage);
                        ctrlValueImage.ContentBytes = imageBytes;
                        ctrlValueImage.Width        = aspectSize.Width;
                        ctrlValueImage.Height       = aspectSize.Height;
                    }
                }
            }
            else
            {
                ctrlEffectiveTo.Date = TimeInterval.MaxDate;
            }
            break;

        //=================================================================================
        default: break;
        }
        //jsonCollection.Add(new JsonStringValue("CallbackType", e.Parameter));
        objs.Add(new JsonBooleanValue("isEffective", isEffective));
        objs.Add(new JsonNumericValue("AttributeID", attributeID));
        cbp.JSProperties[KEY_CP_RESULT] = objs.ToString();
    }
        private void editProgram()
        {
            ReactionProgram editProgram = new ReactionProgram();

            try
            {
                editProgram.readProgramFile(path + Global.programFolderName + editPrgName + ".prg");
            }
            catch (FileNotFoundException e)
            {
                MessageBox.Show(LocRM.GetString("cantEdìtProgramMissingFiles", currentCulture) + e.Message);
                return;
            }

            prgNameTextBox.Text        = editProgram.ProgramName;
            numExpo.Value              = editProgram.NumExpositions;
            expoTime.Value             = editProgram.ExpositionTime;
            intervalTime.Value         = editProgram.IntervalTime;
            beepingCheckbox.Checked    = editProgram.IsBeeping;
            beepDuration.Value         = editProgram.BeepDuration;
            stimuluSize.Value          = (decimal)editProgram.StimuluSize;
            fontSizeUpDown.Value       = editProgram.FontSize;
            positionsBox.SelectedIndex = editProgram.NumberPositions - 1;
            expandImageCheck.Checked   = editProgram.ExpandImage;

            if (editProgram.getHasColorList())
            {
                UniqueColorOption.Checked   = false;
                ColorListOption.Checked     = true;
                openColorListButton.Enabled = true;
                stimulusColor.Enabled       = false;
            }
            if (editProgram.ExpositionRandom)
            {
                isRandomExposition.Checked = true;
            }

            if (editProgram.BeepingRandom)
            {
                randomBeepCheck.Checked = true;
            }

            if (editProgram.StimulusColor != "false")
            {
                stimulusColor.Text           = editProgram.StimulusColor;
                stimulusColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.StimulusColor);
            }
            else
            {
                stimulusColor.Enabled        = false;
                stimulusColorPanel.BackColor = Color.White;
            }
            editProgramShapes(editProgram);
            if (editProgram.ResponseType == "space")
            {
                responseTypeBox.SelectedIndex = 0;
            }
            else if (editProgram.ResponseType == "arrows")
            {
                responseTypeBox.SelectedIndex = 1;
            }

            if (editProgram.getWordListFile() == null)
            {
                openWordListButton.Enabled = false;
            }
            else
            {
                openWordListButton.Enabled = true;
                openWordListButton.Text    = editProgram.getWordListFile().ListName;
            }

            if (editProgram.getColorListFile() == null)
            {
                openColorListButton.Enabled = false;
            }
            else
            {
                openColorListButton.Enabled = true;
                openColorListButton.Text    = editProgram.getColorListFile().ListName;
            }

            if (editProgram.getImageListFile() == null)
            {
                openImgListButton.Enabled = false;
            }
            else
            {
                openImgListButton.Enabled = true;
                openImgListButton.Text    = editProgram.getImageListFile().ListName;
            }

            if (editProgram.getAudioListFile() == null)
            {
                openAudioListButton.Enabled = false;
            }
            else
            {
                openAudioListButton.Enabled = true;
                openAudioListButton.Text    = editProgram.getAudioListFile().ListName;
            }

            if (editProgram.BackgroundColor.ToLower() == "false")
            {
                bgColorPanel.BackColor = Color.White;
                bgColorButton.Text     = LocRM.GetString("choose", currentCulture);
            }

            else
            {
                if ((Validations.isHexPattern(editProgram.BackgroundColor)))
                {
                    bgColorButton.Text     = editProgram.BackgroundColor;
                    bgColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.BackgroundColor);
                }
            }
            if (editProgram.FixPoint == "+")
            {
                fixPointCross.Checked        = true;
                fixPointCircle.Checked       = false;
                fixPointColorButton.Text     = editProgram.FixPointColor;
                fixPointColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.FixPointColor);
            }
            else if (editProgram.FixPoint == "o")
            {
                fixPointCross.Checked        = false;
                fixPointCircle.Checked       = true;
                fixPointColorButton.Text     = editProgram.FixPointColor;
                fixPointColorPanel.BackColor = ColorTranslator.FromHtml(editProgram.FixPointColor);
            }
            else
            {
                fixPointCross.Checked  = false;
                fixPointCircle.Checked = false;
            }

            // reads program instructions to instruction box if there are any
            if (editProgram.InstructionText != null)
            {
                instructionsBox.ForeColor = Color.Black;
                instructionsBox.Text      = editProgram.InstructionText[0];
                for (int i = 1; i < editProgram.InstructionText.Count; i++)
                {
                    instructionsBox.AppendText(Environment.NewLine + editProgram.InstructionText[i]);
                }
            }
            else
            {
                instructionsBox.Text = instructionBoxText;
            }

            switch (editProgram.ExpositionType)
            {
            case "shapes":
                chooseExpoType.SelectedIndex = 0;
                break;

            case "words":
                chooseExpoType.SelectedIndex = 1;
                break;

            case "images":
                chooseExpoType.SelectedIndex = 2;
                break;

            case "imageAndWord":
                chooseExpoType.SelectedIndex = 3;
                break;

            case "wordWithAudio":
                chooseExpoType.SelectedIndex = 4;
                break;

            case "imageWithAudio":
                chooseExpoType.SelectedIndex = 5;
                break;

            default:
                throw new Exception(LocRM.GetString("expoType", currentCulture) + editProgram.ExpositionType + LocRM.GetString("invalid", currentCulture));
            }
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="content"></param>
        /// <param name="qrcodeImgPath"></param>
        /// <param name="wh"></param>
        /// <param name="centerImg"></param>
        /// <param name="color"></param>
        /// <param name="bgcolor"></param>
        /// <returns></returns>
        public static string QrCodeImg(string content, string qrcodeImgPath, int wh, string centerImg, string color, string bgcolor)
        {
            Color foregroundcolor = (color == null || color == "") ? ColorTranslator.FromHtml("#000000") : ColorTranslator.FromHtml(color);
            Color backgroundcolor = (color == null || color == "") ? Color.Transparent : ColorTranslator.FromHtml(bgcolor);
            //Logo 图片
            Bitmap logo = new Bitmap(centerImg);
            //构造二维码写码器
            MultiFormatWriter writer = new MultiFormatWriter();
            Dictionary <EncodeHintType, object> hint = new Dictionary <EncodeHintType, object>();

            hint.Add(EncodeHintType.CHARACTER_SET, "UTF-8");
            hint.Add(EncodeHintType.ERROR_CORRECTION, ZXing.QrCode.Internal.ErrorCorrectionLevel.H);

            //生成二维码
            BitMatrix     bm            = writer.encode(content, BarcodeFormat.QR_CODE, 300, 300, hint);
            BarcodeWriter barcodeWriter = new BarcodeWriter();

            barcodeWriter.Renderer = new ZXing.Rendering.BitmapRenderer {
                Background = backgroundcolor, Foreground = foregroundcolor
            };                                                                                                                         //设置颜色
            Bitmap map = barcodeWriter.Write(bm);


            //获取二维码实际尺寸(去掉二维码两边空白后的实际尺寸)
            int[] rectangle = bm.getEnclosingRectangle();

            //计算插入图片的大小和位置
            int middleW = Math.Min((int)(rectangle[2] / 3.5), logo.Width);
            int middleH = Math.Min((int)(rectangle[3] / 3.5), logo.Height);
            int middleL = (map.Width - middleW) / 2;
            int middleT = (map.Height - middleH) / 2;

            //将img转换成bmp格式,否则后面无法创建Graphics对象
            Bitmap bmpimg = new Bitmap(map.Width, map.Height, PixelFormat.Format32bppArgb);

            using (Graphics g = Graphics.FromImage(bmpimg))
            {
                g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                g.DrawImage(map, 0, 0);
            }
            //将二维码插入图片
            Graphics myGraphic = Graphics.FromImage(bmpimg);

            //白底
            myGraphic.FillRectangle(Brushes.White, middleL, middleT, middleW, middleH);
            myGraphic.DrawImage(logo, middleL, middleT, middleW, middleH);

            //保存成图片
            bmpimg.Save(qrcodeImgPath, ImageFormat.Png);
            bmpimg.Dispose();
            return(qrcodeImgPath);
        }
Пример #8
0
        private void OnDgvDataBindCompleted()
        {
            for (int rowIdx = 0; rowIdx < this.pagedDgvItem.DgvData.Rows.Count; rowIdx++)
            {
                DataGridViewCell cell = this.pagedDgvItem.DgvData.Rows[rowIdx].Cells[2];
                if (cell == null)
                {
                    continue;
                }

                int stockNum = StringUtil.GetSafeInt(cell.Value);
                if (stockNum == 0)
                {
                    this.pagedDgvItem.DgvData.Rows[rowIdx].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#D4D4D6");
                }
            }
        }
Пример #9
0
        private void SplittersMenuClick(object sender, System.EventArgs e)
        {
            BarItem mi = sender as BarItem;

            this.barItem15.Checked = false;
            this.barItem12.Checked = false;
            this.barItem13.Checked = false;
            this.barItem14.Checked = false;
            this.barItem16.Checked = false;

            LockWindowUpdate(this.Handle);
            switch (mi.Text)
            {
            case "Office2016White":
                this.mainFrameBarManager1.Style = VisualStyle.Office2016White;
                this.BackColor = ColorTranslator.FromHtml("#ffffff");
                this.editControl1.BackgroundColor = new Syncfusion.Drawing.BrushInfo(ColorTranslator.FromHtml("#ffffff"));
                this.editControl1.Style           = EditControlStyle.Office2016White;
                this.editControl1.Configurator.Open(configPath);
                this.editControl1.ApplyConfiguration("CustomLanguage");
                this.editControl1.SelectionTextColor = ColorTranslator.FromHtml("#bfdfff");
                mi.Checked = true;

                break;

            case "Default":
                this.mainFrameBarManager1.Style = VisualStyle.Office2016White;
                this.BackColor = ColorTranslator.FromHtml("#ffffff");
                this.editControl1.BackgroundColor = new Syncfusion.Drawing.BrushInfo(ColorTranslator.FromHtml("#ffffff"));
                this.editControl1.Style           = EditControlStyle.Default;
                this.editControl1.Configurator.Open(configPath);
                this.editControl1.ApplyConfiguration("CustomLanguage");
                this.editControl1.SelectionTextColor = ColorTranslator.FromHtml("#bfdfff");

                mi.Checked = true;

                break;

            case "Office2016DarkGray":
                this.mainFrameBarManager1.Style = VisualStyle.Office2016DarkGray;
                this.BackColor = ColorTranslator.FromHtml("#444444");
                this.editControl1.BackgroundColor = new Syncfusion.Drawing.BrushInfo(ColorTranslator.FromHtml("#2d2d30"));
                this.editControl1.Style           = EditControlStyle.Office2016DarkGray;
                this.editControl1.Configurator.Open(white);
                this.editControl1.ApplyConfiguration("C#");
                this.editControl1.SelectionTextColor = ColorTranslator.FromHtml("#0173c7");
                mi.Checked = true;

                break;

            case "Office2016Colorful":
                this.mainFrameBarManager1.Style = VisualStyle.Office2016Colorful;
                this.BackColor = ColorTranslator.FromHtml("#0173c7");
                this.editControl1.BackgroundColor    = new Syncfusion.Drawing.BrushInfo(ColorTranslator.FromHtml("#ffffff"));
                this.editControl1.Style              = EditControlStyle.Office2016Colorful;
                this.editControl1.SelectionTextColor = ColorTranslator.FromHtml("#bfdfff");
                this.editControl1.Configurator.Open(configPath);
                mi.Checked = true;

                break;

            case "Office2016Black":
                this.BackColor = ColorTranslator.FromHtml("#0a0a0a");
                this.mainFrameBarManager1.Style   = VisualStyle.Office2016Black;
                this.editControl1.BackgroundColor = new Syncfusion.Drawing.BrushInfo(ColorTranslator.FromHtml("#0a0a0a"));
                this.editControl1.Style           = EditControlStyle.Office2016Black;
                this.editControl1.Configurator.Open(white);
                this.editControl1.ApplyConfiguration("C#");
                this.editControl1.SelectionTextColor = ColorTranslator.FromHtml("#0173c7");

                mi.Checked = true;
                break;
            }
            LockWindowUpdate(IntPtr.Zero);
        }
Пример #10
0
        public async Task Ship(IUser user1, IUser user2, IUser user3 = null)
        {
            bool hasThreeUsers = user1 != null && user2 != null && user3 != null;

            // Validation check.
            if (user1 == null || user2 == null)
            {
                await Context.ApplyResultReaction(CommandResult.Failed).ConfigureAwait(false);

                return;
            }

            // Check for duplicate users when calculating a three way ship.
            if (hasThreeUsers &&
                user1 == user2 || user1 == user3 || user2 == user3)
            {
                await Context.ApplyResultReaction(CommandResult.Failed).ConfigureAwait(false);

                return;
            }


            // Randomize shipping.
            var randomizer       = new Randomizer((ulong)DateTime.UtcNow.Date.Ticks, user1.Id, user2.Id);
            var percent          = GetTodayRandomizer(user1.Id, user2.Id, user3?.Id ?? 0).New(0, 100);
            var highestKey       = _shipLevels.Keys.OrderBy(x => x).LastOrDefault(k => percent >= k);
            var resultMessage    = _shipLevels[highestKey].Item1;
            var resultColorBrush = new SolidBrush(ColorTranslator.FromHtml(_shipLevels[highestKey].Item2));
            var resultHeartText  = _shipHeartLevels[_shipHeartLevels.Keys.OrderBy(x => x).LastOrDefault(k => percent >= k)];

            // Constant variables to setup the rendering bit.
            const int circleSize        = 128;
            const int margin            = 200;
            const int borderMargin      = 50;
            const int circleMarginY     = 50;
            const int imgWidth          = (circleSize * 2) + (borderMargin * 2) + margin;
            float     resultStartOffset = 50f + (hasThreeUsers ? 15f : 0f);
            var       circleColour      = System.Drawing.Color.Gray;
            const int scale             = 4;
            // Dynamic
            int         imgHeight        = (circleSize + circleMarginY + 30) * (hasThreeUsers ? 2 : 1);
            const float circleBorderSize = 1.5f;

            // Can't seem to render UTF-32 characters on Linux, so instead using an image.
            var heartImg = System.Drawing.Image.FromFile($@"data/images/hearts/{resultHeartText}");

            heartImg = ImageHelper.ReplacePixelColours(heartImg, resultColorBrush.Color);

            // Setup fonts
            // There seems to be a bug in .net core, but this does work on Windows.
            FontCollection fontCollection = new InstalledFontCollection();

            if (BaseClass.IsWindows())
            {
                var privateFontCollection = new PrivateFontCollection();
                privateFontCollection.AddFontFile("data/fonts/Pinky Cupid.otf");
                fontCollection = privateFontCollection;
            }

            FontFamily fallbackFontFamily   = new FontFamily("Arial");
            FontFamily pinkyCupidFontFamily = fontCollection.Families.FirstOrDefault(x => string.Equals(x.Name, "Pinky Cupid", StringComparison.CurrentCultureIgnoreCase)) ?? fallbackFontFamily;


            var bmp       = new Bitmap(imgWidth, imgHeight, PixelFormat.Format32bppArgb);
            var bmpScaled = new Bitmap(imgWidth * scale, imgHeight * scale, PixelFormat.Format32bppArgb);

            using (var g = Graphics.FromImage(bmpScaled))
            {
                g.SetupForHighQuality();

                float       resultStartOffsetScaled = resultStartOffset * scale;
                const float resultPercentageMargin  = 20f * scale;
                const float resultMessageMargin     = 12.5f * scale;
                const float nameMarginY             = 5f;
                var         resultHeartSize         = new Size(heartImg.Width * scale, heartImg.Height * scale);

                var fontHeader = new Font(pinkyCupidFontFamily, 22f * scale);
                var headerText = "~Compatibility Meter~";
                var headerSize = g.MeasureString(headerText, fontHeader);
                g.DrawString(headerText, fontHeader, Brushes.Salmon, ((imgWidth * scale) - headerSize.Width) / 2f, 0);

                // Moved to an image due to UTF-32 rendering issues on linux.
                //var fontResultHeart = new Font("Segoe UI Emoji", 32f);
                //var resultHeartSize = g.MeasureString(resultHeartText, fontResultHeart);
                //g.DrawString(resultHeartText, fontResultHeart, resultColorBrush, (imgWidth - resultHeartSize.Width) / 2f, 50f);

                var fontPercentage = new Font(pinkyCupidFontFamily, 18f * scale);
                var percentageText = $"~{percent}%~";
                var percentageSize = g.MeasureString(percentageText, fontPercentage);
                g.DrawString(percentageText, fontPercentage, resultColorBrush, ((imgWidth * scale) - percentageSize.Width) / 2f, resultStartOffsetScaled + resultHeartSize.Height + resultPercentageMargin);

                var fontResultMessage = new Font(pinkyCupidFontFamily, 18f * scale);
                var resultMessageSize = g.MeasureString(resultMessage, fontPercentage);
                g.DrawString(resultMessage, fontResultMessage, resultColorBrush, ((imgWidth * scale) - resultMessageSize.Width) / 2f, resultStartOffsetScaled + percentageSize.Height + resultHeartSize.Height + resultMessageMargin);

                var fontName  = new Font(pinkyCupidFontFamily, 18f * scale);
                var nameText1 = (user1 as IGuildUser)?.Nickname ?? user1.Username;
                var nameText2 = (user2 as IGuildUser)?.Nickname ?? user2.Username;
                var nameSize1 = g.MeasureString(nameText1, fontName);
                var nameSize2 = g.MeasureString(nameText2, fontName);
                g.DrawString(nameText1, fontName, Brushes.Gray, ((borderMargin + (circleSize / 2)) * scale) - (nameSize1.Width / 2f), (circleMarginY + circleSize + nameMarginY) * scale);
                g.DrawString(nameText2, fontName, Brushes.Gray, ((imgWidth - borderMargin - (circleSize / 2)) * scale) - (nameSize2.Width / 2f), (circleMarginY + circleSize + nameMarginY) * scale);

                if (hasThreeUsers)
                {
                    var nameText3 = (user3 as IGuildUser)?.Nickname ?? user3?.Username;
                    var nameSize3 = g.MeasureString(nameText3, fontName);
                    g.DrawString(nameText3, fontName, Brushes.Gray, ((imgWidth * scale) - nameSize3.Width) / 2, (circleSize + circleSize + circleMarginY + 50 + nameMarginY) * scale);
                }
            }

            using (var g = Graphics.FromImage(bmp))
            {
                g.SetupForHighQuality();

                // Copy scaled image on top of this one
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.DrawImage(bmpScaled, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmpScaled.Width, bmpScaled.Height, GraphicsUnit.Pixel);

                // Avatar circles
                Bitmap avatar1 = null, avatar2 = null, avatar3 = null;
                try
                {
                    var avatarUrl1 = user1.GetAvatarUrl(Discord.ImageFormat.Jpeg, 128);
                    var avatarUrl2 = user2.GetAvatarUrl(Discord.ImageFormat.Jpeg, 128);
                    var avatarUrl3 = user3?.GetAvatarUrl(Discord.ImageFormat.Jpeg, 128);


                    var avatarStream1 = await WebHelper.GetStreamAsync(avatarUrl1).ConfigureAwait(false);

                    avatar1 = new Bitmap(avatarStream1);

                    var avatarStream2 = await WebHelper.GetStreamAsync(avatarUrl2).ConfigureAwait(false);

                    avatar2 = new Bitmap(avatarStream2);

                    if (hasThreeUsers)
                    {
                        var avatarStream3 = await WebHelper.GetStreamAsync(avatarUrl3).ConfigureAwait(false);

                        avatar3 = new Bitmap(avatarStream3);
                    }
                }
                catch { }

                if (avatar1 == null)
                {
                    avatar1 = new Bitmap(128, 128);
                }
                if (avatar2 == null)
                {
                    avatar2 = new Bitmap(128, 128);
                }
                if (avatar3 == null)
                {
                    avatar3 = new Bitmap(128, 128);
                }

                ImageHelper.DrawImageInCircle(g, avatar1, new PointF(borderMargin, circleMarginY), circleColour, circleBorderSize);
                ImageHelper.DrawImageInCircle(g, avatar2, new PointF(imgWidth - borderMargin - circleSize, circleMarginY), circleColour, circleBorderSize);
                ImageHelper.DrawImageInCircle(g, avatar3, new PointF((imgWidth - circleSize) / 2, circleSize + circleMarginY + 50), circleColour, circleBorderSize);

                // Heart image
                g.DrawImage(heartImg, ((imgWidth - heartImg.Width) / 2f), (resultStartOffset + 10f));
            }

            using var ms = new MemoryStream();
            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            ms.Position = 0;
            await Context.Channel.SendFileAsync(ms, $"ship.png").ConfigureAwait(false);
        }
Пример #11
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
     this.rangeSlider1 = new Syncfusion.Windows.Forms.Tools.RangeSlider();
     this.rangeSlider2 = new Syncfusion.Windows.Forms.Tools.RangeSlider();
     this.rangeSlider3 = new Syncfusion.Windows.Forms.Tools.RangeSlider();
     this.label1       = new System.Windows.Forms.Label();
     this.label2       = new System.Windows.Forms.Label();
     this.label3       = new System.Windows.Forms.Label();
     this.panel1       = new System.Windows.Forms.Panel();
     this.label4       = new System.Windows.Forms.Label();
     this.panel1.SuspendLayout();
     this.SuspendLayout();
     //
     // rangeSlider1
     //
     this.rangeSlider1.VisualStyle           = Syncfusion.Windows.Forms.Tools.RangeSlider.RangeSliderStyle.Office2016Colorful;
     this.rangeSlider1.BeforeTouchSize       = new System.Drawing.Size(800, 52);
     this.rangeSlider1.ChannelColor          = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(197)))), ((int)(((byte)(197)))));
     this.rangeSlider1.Font                  = new System.Drawing.Font("Segoe UI Semibold", 8F);
     this.rangeSlider1.ForeColor             = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68)))));
     this.rangeSlider1.HighlightedThumbColor = System.Drawing.Color.FromArgb(((int)(((byte)(1)))), ((int)(((byte)(115)))), ((int)(((byte)(199)))));
     this.rangeSlider1.Location              = new System.Drawing.Point(65, 135);
     this.rangeSlider1.Maximum               = 100;
     this.rangeSlider1.Name                  = "rangeSlider1";
     this.rangeSlider1.PushedThumbColor      = System.Drawing.Color.FromArgb(((int)(((byte)(1)))), ((int)(((byte)(86)))), ((int)(((byte)(148)))));
     this.rangeSlider1.RangeColor            = ColorTranslator.FromHtml("#106ebe");
     this.rangeSlider1.ShowLabels            = true;
     this.rangeSlider1.ShowTicks             = false;
     this.rangeSlider1.Size                  = new System.Drawing.Size(800, 52);
     this.rangeSlider1.SliderMax             = 40;
     this.rangeSlider1.SliderSize            = new System.Drawing.Size(5, 18);
     this.rangeSlider1.TabIndex              = 0;
     this.rangeSlider1.Text                  = "rangeSlider1";
     this.rangeSlider1.ThumbColor            = ColorTranslator.FromHtml("#106ebe");
     this.rangeSlider1.TickColor             = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(197)))), ((int)(((byte)(197)))));
     this.rangeSlider1.TickFrequency         = 20;
     this.rangeSlider1.DrawLabel            += RangeSlider1_DrawLabel;
     //
     // rangeSlider2
     //
     this.rangeSlider2.VisualStyle           = Syncfusion.Windows.Forms.Tools.RangeSlider.RangeSliderStyle.Office2016Colorful;
     this.rangeSlider2.BeforeTouchSize       = new System.Drawing.Size(800, 52);
     this.rangeSlider2.ChannelColor          = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(197)))), ((int)(((byte)(197)))));
     this.rangeSlider2.Font                  = new System.Drawing.Font("Segoe UI Semibold", 8F);
     this.rangeSlider2.ForeColor             = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68)))));
     this.rangeSlider2.HighlightedThumbColor = System.Drawing.Color.FromArgb(((int)(((byte)(1)))), ((int)(((byte)(115)))), ((int)(((byte)(199)))));
     this.rangeSlider2.Location              = new System.Drawing.Point(65, 295);
     this.rangeSlider2.Maximum               = 2100;
     this.rangeSlider2.SliderMax             = 1700;
     this.rangeSlider2.Minimum               = 900;
     this.rangeSlider2.SliderMin             = 1300;
     this.rangeSlider2.Name                  = "rangeSlider2";
     this.rangeSlider2.PushedThumbColor      = System.Drawing.Color.FromArgb(((int)(((byte)(1)))), ((int)(((byte)(86)))), ((int)(((byte)(148)))));
     this.rangeSlider2.RangeColor            = ColorTranslator.FromHtml("#106ebe");
     this.rangeSlider2.ShowLabels            = true;
     this.rangeSlider2.ShowTicks             = false;
     this.rangeSlider2.Size                  = new System.Drawing.Size(800, 52);
     this.rangeSlider2.SliderSize            = new System.Drawing.Size(5, 18);
     this.rangeSlider2.TabIndex              = 1;
     this.rangeSlider2.Text                  = "rangeSlider2";
     this.rangeSlider2.ThumbColor            = ColorTranslator.FromHtml("#106ebe");
     this.rangeSlider2.TickColor             = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(197)))), ((int)(((byte)(197)))));
     this.rangeSlider2.TickFrequency         = 400;
     this.rangeSlider2.DrawLabel            += RangeSlider2_DrawLabel;
     //
     // rangeSlider3
     //
     this.rangeSlider3.VisualStyle           = Syncfusion.Windows.Forms.Tools.RangeSlider.RangeSliderStyle.Office2016Colorful;
     this.rangeSlider3.BeforeTouchSize       = new System.Drawing.Size(800, 52);
     this.rangeSlider3.ChannelColor          = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(197)))), ((int)(((byte)(197)))));
     this.rangeSlider3.Font                  = new System.Drawing.Font("Segoe UI Semibold", 8F);
     this.rangeSlider3.ForeColor             = System.Drawing.Color.FromArgb(((int)(((byte)(68)))), ((int)(((byte)(68)))), ((int)(((byte)(68)))));
     this.rangeSlider3.HighlightedThumbColor = System.Drawing.Color.FromArgb(((int)(((byte)(1)))), ((int)(((byte)(115)))), ((int)(((byte)(199)))));
     this.rangeSlider3.Location              = new System.Drawing.Point(65, 457);
     this.rangeSlider3.Maximum               = 23;
     this.rangeSlider3.SliderMax             = 23;
     this.rangeSlider3.Minimum               = 8;
     this.rangeSlider3.SliderMin             = 17;
     this.rangeSlider3.Name                  = "rangeSlider3";
     this.rangeSlider3.PushedThumbColor      = System.Drawing.Color.FromArgb(((int)(((byte)(1)))), ((int)(((byte)(86)))), ((int)(((byte)(148)))));
     this.rangeSlider3.RangeColor            = ColorTranslator.FromHtml("#106ebe");
     this.rangeSlider3.ShowLabels            = true;
     this.rangeSlider3.ShowTicks             = false;
     this.rangeSlider3.Size                  = new System.Drawing.Size(800, 52);
     this.rangeSlider3.SliderSize            = new System.Drawing.Size(5, 18);
     this.rangeSlider3.TabIndex              = 2;
     this.rangeSlider3.Text                  = "rangeSlider3";
     this.rangeSlider3.ThumbColor            = ColorTranslator.FromHtml("#106ebe");
     this.rangeSlider3.TickColor             = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(197)))), ((int)(((byte)(197)))));
     this.rangeSlider3.TickFrequency         = 3;
     this.rangeSlider3.DrawLabel            += RangeSlider3_DrawLabel;
     //
     // label1
     //
     this.label1.AutoSize = true;
     this.label1.Font     = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold);
     this.label1.Location = new System.Drawing.Point(70, 89);
     this.label1.Name     = "label1";
     this.label1.Size     = new System.Drawing.Size(121, 21);
     this.label1.TabIndex = 3;
     this.label1.Text     = "Currency Slider";
     //
     // label2
     //
     this.label2.AutoSize = true;
     this.label2.Font     = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold);
     this.label2.Location = new System.Drawing.Point(70, 247);
     this.label2.Name     = "label2";
     this.label2.Size     = new System.Drawing.Size(128, 21);
     this.label2.TabIndex = 4;
     this.label2.Text     = "Kilometer Slider";
     //
     // label3
     //
     this.label3.AutoSize = true;
     this.label3.Font     = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold);
     this.label3.Location = new System.Drawing.Point(70, 401);
     this.label3.Name     = "label3";
     this.label3.Size     = new System.Drawing.Size(92, 21);
     this.label3.TabIndex = 5;
     this.label3.Text     = "Time Slider";
     //
     // panel1
     //
     this.panel1.Controls.Add(this.label4);
     this.panel1.Location = new System.Drawing.Point(1, -1);
     this.panel1.Name     = "panel1";
     this.panel1.Size     = new System.Drawing.Size(994, 51);
     this.panel1.TabIndex = 6;
     //
     // label4
     //
     this.label4.Dock     = System.Windows.Forms.DockStyle.Left;
     this.label4.Font     = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.label4.Location = new System.Drawing.Point(0, 5);
     this.label4.Name     = "label4";
     this.label4.Size     = new System.Drawing.Size(991, 51);
     this.label4.TabIndex = 0;
     this.label4.Text     = "The following sample demonstates the customization of text, font and color of the" +
                            " labels present in RangeSlider, which helps in converting the labels into currency" +
                            ", kilometer and time format.";
     //
     // Form1
     //
     this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.BackColor           = System.Drawing.Color.White;
     this.Style.Border        = new Pen(System.Drawing.Color.FromArgb(((int)(((byte)(244)))), ((int)(((byte)(244)))), ((int)(((byte)(244))))), 5);
     this.Style.ShadowOpacity = 0;
     this.ClientSize          = new System.Drawing.Size(993, 646);
     this.Controls.Add(this.panel1);
     this.Controls.Add(this.label3);
     this.Controls.Add(this.label2);
     this.Controls.Add(this.label1);
     this.Controls.Add(this.rangeSlider3);
     this.Controls.Add(this.rangeSlider2);
     this.Controls.Add(this.rangeSlider1);
     this.Icon          = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MaximizeBox   = false;
     this.MaximumSize   = this.Size;
     this.MinimumSize   = this.Size;
     this.Name          = "Form1";
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text          = "Slider Formatting";
     this.panel1.ResumeLayout(false);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
Пример #12
0
        private void metroButton_check_job_arithmetic_operations_Click(object sender, EventArgs e)//Кнопка "Продолжить"
        {
            string task_for_equall  = "int height_anhel_waterfall = 979;";
            string task_for_equall1 = "float colibri_size = 5.7;";
            string task_for_equall2 = "char first_letter_alphabet = 'A';";
            string task_for_equall3 = "double golden_section = 1.61803398875;";
            string task_for_equall4 = "bool is_round_earth = true;";

            string task_for_plus = "int earth_radius = depth_to_core_earth+avg_radius_core;";

            string task_for_minus = "int height_diff = qomolangma - chogori;";

            string task_for_multiplication = "int square = number * number;";

            string task_for_division  = "division = 5 / 2;";
            string task_for_division1 = "rem_division = 5 % 2;";
            string task_for_division2 = "double float_division = 5.0 / 2.0;";

            string task_for_finich = "int discriminant = b * b - 4 * a * c;";

            switch (current_button)
            {
            case 1: {
                Function.Update_table_passing("obschee_arithmetic_operations");
                metroTile_obschee_arithmetic_operations.BackColor = ColorTranslator.FromHtml("#47a447");
                metroTile_equally_Click(sender, e);
                break;
            }

            case 2: {
                if (fastColoredTextBox_code.Text.Contains(task_for_equall) && fastColoredTextBox_code.Text.Contains(task_for_equall1) &&
                    fastColoredTextBox_code.Text.Contains(task_for_equall2) && fastColoredTextBox_code.Text.Contains(task_for_equall3) &&
                    fastColoredTextBox_code.Text.Contains(task_for_equall4))
                {
                    Function.Update_table_passing("equally");
                    metroTile_equally.BackColor = ColorTranslator.FromHtml("#47a447");
                    metroTile_plus_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("Задание выполнено неправильно. Исправьте код и попробуйте снова.", "Ошибка");
                }

                break;
            }

            case 3:
            {
                if (fastColoredTextBox_code.Text.Contains(task_for_plus))
                {
                    Function.Update_table_passing("plus_arithmetic_operations");
                    metroTile_plus.BackColor = ColorTranslator.FromHtml("#47a447");
                    metroTile_minus_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("Задание выполнено неправильно. Исправьте код и попробуйте снова.", "Ошибка");
                }

                break;
            }

            case 4:
            {
                if (fastColoredTextBox_code.Text.Contains(task_for_minus))
                {
                    Function.Update_table_passing("minus_arithmetic_operations");
                    metroTile_minus.BackColor = ColorTranslator.FromHtml("#47a447");
                    metroTile_multiplication_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("Задание выполнено неправильно. Исправьте код и попробуйте снова.", "Ошибка");
                }

                break;
            }

            case 5:
            {
                if (fastColoredTextBox_code.Text.Contains(task_for_multiplication))
                {
                    Function.Update_table_passing("multiplication_arithmetic_operations");
                    metroTile_multiplication.BackColor = ColorTranslator.FromHtml("#47a447");
                    metroTile_division_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("Задание выполнено неправильно. Исправьте код и попробуйте снова.", "Ошибка");
                }

                break;
            }

            case 6:
            {
                if (fastColoredTextBox_code.Text.Contains(task_for_division) && fastColoredTextBox_code.Text.Contains(task_for_division1) && fastColoredTextBox_code.Text.Contains(task_for_division2))
                {
                    Function.Update_table_passing("division_arithmetic_operations");
                    metroTile_division.BackColor = ColorTranslator.FromHtml("#47a447");
                    metroTile_finish_arithmetic_operations_Click(sender, e);
                }
                else
                {
                    MessageBox.Show("Задание выполнено неправильно. Исправьте код и попробуйте снова.", "Ошибка");
                }

                break;
            }

            case 7:
            {
                if (fastColoredTextBox_code.Text.Contains(task_for_finich))
                {
                    Function.Update_table_passing("finish_arithmetic_operations");
                    metroTile_finish_arithmetic_operations.BackColor = ColorTranslator.FromHtml("#47a447");
                    if (MessageBox.Show("Вы прошли курс \"Арифметические операции \". Желаеете продолжить", "Поздравление", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                    {
                        if (!Form2.Instance.MetroPanel.Controls.ContainsKey("Input_Output"))
                        {
                            Input_Output profile = new Input_Output();
                            profile.Dock = DockStyle.Fill;
                            Form2.Instance.MetroPanel.Controls.Add(profile);
                        }
                        Form2.Instance.MetroPanel.Controls["Input_Output"].BringToFront();
                        Form2.Instance.MetroBack.Visible = true;
                    }
                }
                else
                {
                    MessageBox.Show("Задание выполнено неправильно. Исправьте код и попробуйте снова.", "Ошибка");
                }

                break;
            }
            }
        }
Пример #13
0
        /// <summary>
        /// Gets the color.
        /// </summary>
        /// <param name="style">The style to get the color from. The parameter part gets removed from it.</param>
        /// <param name="parameter">The parameter whose color should be returned.</param>
        /// <returns>Black color / white fill color if nothing was found otherwise the color that was found.</returns>
        private static Color GetColor(ref string style, Parameter parameter)
        {
            var color = GetValue(ref style, parameter.Name);

            return(string.IsNullOrWhiteSpace(color) ? parameter.DefaultColor : ColorTranslator.FromHtml(color));
        }
Пример #14
0
 private void genreMenuMouseHover(object sender, EventArgs e)
 {
     ((Label)sender).BackColor = ColorTranslator.FromHtml("#2b2b2b");
 }
Пример #15
0
 /// <devdoc>
 ///     Sets the DC background color and returns the old value.
 /// </devdoc>
 public Color SetBackgroundColor(Color newColor)
 {
     return(ColorTranslator.FromWin32(IntUnsafeNativeMethods.SetBkColor(new HandleRef(this, this.Hdc), ColorTranslator.ToWin32(newColor))));
 }
Пример #16
0
        // Add image generation logic here and return an instance of ImageInfo
        public override ImageInfo GenerateImage(NameValueCollection parameters)
        {
            SetupCulture();

            //which type of image should be generated ?
            string mode = string.IsNullOrEmpty(parameters["mode"]) ? "profilepic" : parameters["mode"].ToLowerInvariant();

            // We need to determine the output format
            string format = string.IsNullOrEmpty(parameters["format"]) ? "jpg" : parameters["format"].ToLowerInvariant();

            // Lets retrieve the color
            Color color     = string.IsNullOrEmpty(parameters["color"]) ? Color.White : (parameters["color"].StartsWith("#") ? ColorTranslator.FromHtml(parameters["color"]) : Color.FromName(parameters["color"]));
            Color backColor = string.IsNullOrEmpty(parameters["backcolor"]) ? Color.White : (parameters["backcolor"].StartsWith("#") ? ColorTranslator.FromHtml(parameters["backcolor"]) : Color.FromName(parameters["backcolor"]));

            // Do we have a border ?
            int border = string.IsNullOrEmpty(parameters["border"]) ? 0 : Convert.ToInt32(parameters["border"]);

            // Do we have a resizemode defined ?
            var resizeMode = string.IsNullOrEmpty(parameters["resizemode"]) ? ImageResizeMode.Fit : (ImageResizeMode)Enum.Parse(typeof(ImageResizeMode), parameters["ResizeMode"], true);

            // Maximum sizes
            int maxWidth  = string.IsNullOrEmpty(parameters["MaxWidth"]) ? 0 : Convert.ToInt32(parameters["MaxWidth"]);
            int maxHeight = string.IsNullOrEmpty(parameters["MaxHeight"]) ? 0 : Convert.ToInt32(parameters["MaxHeight"]);

            // Any text ?
            string text = string.IsNullOrEmpty(parameters["text"]) ? "" : parameters["text"];

            // Default Image
            _defaultImageFile = string.IsNullOrEmpty(parameters["NoImage"]) ? string.Empty : parameters["NoImage"];

            // Do we override caching for this image ?
            if (!string.IsNullOrEmpty(parameters["NoCache"]))
            {
                EnableClientCache = false;
                EnableServerCache = false;
            }

            try
            {
                ContentType = GetImageFormat(format);

                switch (mode)
                {
                case "profilepic":
                    int uid;
                    if (!int.TryParse(parameters["userid"], out uid) || uid <= 0)
                    {
                        uid = -1;
                    }
                    var uppTrans = new UserProfilePicTransform
                    {
                        UserID = uid
                    };

                    IFileInfo photoFile;
                    ContentType = !uppTrans.TryGetPhotoFile(out photoFile)
                            ? ImageFormat.Gif
                            : GetImageFormat(photoFile?.Extension ?? "jpg");

                    ImageTransforms.Add(uppTrans);
                    break;

                case "placeholder":
                    var placeHolderTrans = new PlaceholderTransform();
                    int width, height;
                    if (TryParseDimension(parameters["w"], out width))
                    {
                        placeHolderTrans.Width = width;
                    }
                    if (TryParseDimension(parameters["h"], out height))
                    {
                        placeHolderTrans.Height = height;
                    }
                    if (!string.IsNullOrEmpty(parameters["Color"]))
                    {
                        placeHolderTrans.Color = color;
                    }
                    if (!string.IsNullOrEmpty(parameters["Text"]))
                    {
                        placeHolderTrans.Text = text;
                    }
                    if (!string.IsNullOrEmpty(parameters["BackColor"]))
                    {
                        placeHolderTrans.BackColor = backColor;
                    }

                    ImageTransforms.Add(placeHolderTrans);
                    break;

                case "securefile":
                    var secureFileTrans = new SecureFileTransform();
                    if (!string.IsNullOrEmpty(parameters["FileId"]))
                    {
                        var fileId = Convert.ToInt32(parameters["FileId"]);
                        var file   = FileManager.Instance.GetFile(fileId);
                        if (file == null)
                        {
                            return(GetEmptyImageInfo());
                        }
                        var folder = FolderManager.Instance.GetFolder(file.FolderId);
                        if (!secureFileTrans.DoesHaveReadFolderPermission(folder))
                        {
                            return(GetEmptyImageInfo());
                        }
                        ContentType = GetImageFormat(file.Extension);
                        secureFileTrans.SecureFile = file;
                        secureFileTrans.EmptyImage = EmptyImage;
                        ImageTransforms.Add(secureFileTrans);
                    }
                    break;

                case "file":
                    var imgFile = string.Empty;
                    var imgUrl  = string.Empty;

                    // Lets determine the 2 types of Image Source: Single file, file url
                    var filePath = parameters["File"];
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        filePath = filePath.Trim();
                        var fullFilePath = HttpContext.Current.Server.MapPath(filePath);
                        if (!File.Exists(fullFilePath) || !IsAllowedFilePathImage(filePath))
                        {
                            return(GetEmptyImageInfo());
                        }
                        imgFile = fullFilePath;
                    }
                    else if (!string.IsNullOrEmpty(parameters["Url"]))
                    {
                        var url = parameters["Url"];
                        // allow only site resources when using the url parameter
                        if (!url.StartsWith("http") || !UriBelongsToSite(new Uri(url)))
                        {
                            return(GetEmptyImageInfo());
                        }

                        imgUrl = url;
                    }

                    if (string.IsNullOrEmpty(parameters["format"]))
                    {
                        string extension;
                        if (string.IsNullOrEmpty(parameters["Url"]))
                        {
                            var fi = new System.IO.FileInfo(imgFile);
                            extension = fi.Extension.ToLowerInvariant();
                        }
                        else
                        {
                            string[] parts = parameters["Url"].Split('.');
                            extension = parts[parts.Length - 1].ToLowerInvariant();
                        }
                        ContentType = GetImageFormat(extension);
                    }
                    var imageFileTrans = new ImageFileTransform {
                        ImageFilePath = imgFile, ImageUrl = imgUrl
                    };
                    ImageTransforms.Add(imageFileTrans);
                    break;

                default:

                    string   imageTransformClass      = ConfigurationManager.AppSettings["DnnImageHandler." + mode];
                    string[] imageTransformClassParts = imageTransformClass.Split(',');
                    var      asm = Assembly.LoadFrom(Globals.ApplicationMapPath + @"\bin\" +
                                                     imageTransformClassParts[1].Trim() + ".dll");
                    var t = asm.GetType(imageTransformClassParts[0].Trim());
                    var imageTransform = (ImageTransform)Activator.CreateInstance(t);

                    foreach (var key in parameters.AllKeys)
                    {
                        var pi = t.GetProperty(key, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
                        if (pi != null && key != "mode")
                        {
                            switch (key.ToLowerInvariant())
                            {
                            case "color":
                                pi.SetValue(imageTransform, color, null);
                                break;

                            case "backcolor":
                                pi.SetValue(imageTransform, backColor, null);
                                break;

                            case "border":
                                pi.SetValue(imageTransform, border, null);
                                break;

                            default:
                                switch (pi.PropertyType.Name)
                                {
                                case "Int32":
                                    pi.SetValue(imageTransform, Convert.ToInt32(parameters[key]), null);
                                    break;

                                case "String":
                                    pi.SetValue(imageTransform, parameters[key], null);
                                    break;
                                }
                                break;
                            }
                        }
                    }
                    ImageTransforms.Add(imageTransform);
                    break;
                }
            }
            catch (Exception ex)
            {
                Exceptions.Exceptions.LogException(ex);
                return(GetEmptyImageInfo());
            }

            // Resize-Transformation
            if (mode != "placeholder")
            {
                int width, height;

                TryParseDimension(parameters["w"], out width);
                TryParseDimension(parameters["h"], out height);

                var size = string.IsNullOrEmpty(parameters["size"]) ? "" : parameters["size"];

                switch (size)
                {
                case "xxs":
                    width  = 16;
                    height = 16;
                    break;

                case "xs":
                    width  = 32;
                    height = 32;
                    break;

                case "s":
                    width  = 50;
                    height = 50;
                    break;

                case "l":
                    width  = 64;
                    height = 64;
                    break;

                case "xl":
                    width  = 128;
                    height = 128;
                    break;

                case "xxl":
                    width  = 256;
                    height = 256;
                    break;
                }

                if (mode == "profilepic")
                {
                    resizeMode = ImageResizeMode.FitSquare;
                    if (width > 0 && height > 0 && width != height)
                    {
                        resizeMode = ImageResizeMode.Fill;
                    }
                }

                if (width > 0 || height > 0)
                {
                    var resizeTrans = new ImageResizeTransform
                    {
                        Mode      = resizeMode,
                        BackColor = backColor,
                        Width     = width,
                        Height    = height,
                        MaxWidth  = maxWidth,
                        MaxHeight = maxHeight,
                        Border    = border
                    };
                    ImageTransforms.Add(resizeTrans);
                }
            }

            // Gamma adjustment
            if (!string.IsNullOrEmpty(parameters["Gamma"]))
            {
                var    gammaTrans = new ImageGammaTransform();
                double gamma;
                if (double.TryParse(parameters["Gamma"], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out gamma) && gamma >= 0.2 && gamma <= 5)
                {
                    gammaTrans.Gamma = gamma;
                    ImageTransforms.Add(gammaTrans);
                }
            }

            // Brightness adjustment
            if (!string.IsNullOrEmpty(parameters["Brightness"]))
            {
                var brightnessTrans = new ImageBrightnessTransform();
                int brightness;
                if (int.TryParse(parameters["Brightness"], out brightness))
                {
                    brightnessTrans.Brightness = brightness;
                    ImageTransforms.Add(brightnessTrans);
                }
            }

            // Contrast adjustment
            if (!string.IsNullOrEmpty(parameters["Contrast"]))
            {
                var    contrastTrans = new ImageContrastTransform();
                double contrast;
                if (double.TryParse(parameters["Contrast"], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out contrast) && (contrast >= -100 && contrast <= 100))
                {
                    contrastTrans.Contrast = contrast;
                    ImageTransforms.Add(contrastTrans);
                }
            }

            // Greyscale
            if (!string.IsNullOrEmpty(parameters["Greyscale"]))
            {
                var greyscaleTrans = new ImageGreyScaleTransform();
                ImageTransforms.Add(greyscaleTrans);
            }

            // Invert
            if (!string.IsNullOrEmpty(parameters["Invert"]))
            {
                var invertTrans = new ImageInvertTransform();
                ImageTransforms.Add(invertTrans);
            }

            // Rotate / Flip
            if (!string.IsNullOrEmpty(parameters["RotateFlip"]))
            {
                var rotateFlipTrans = new ImageRotateFlipTransform();
                var rotateFlipType  = (RotateFlipType)Enum.Parse(typeof(RotateFlipType), parameters["RotateFlip"]);
                rotateFlipTrans.RotateFlip = rotateFlipType;
                ImageTransforms.Add(rotateFlipTrans);
            }

            // We start the chain with an empty image
            var dummy = new Bitmap(1, 1);

            using (var ms = new MemoryStream())
            {
                dummy.Save(ms, ContentType);
                return(new ImageInfo(ms.ToArray()));
            }
        }
Пример #17
0
        private void parse_text(XmlNodeList nodes)
        {
            double x, y, width, height, font_size;
            string align, font_family, font_style, prefix, suffix;
            bool   include_other_notes;
            Color  color;

            foreach (XmlNode node in nodes)
            {
                if (node.Attributes.Count > 0)
                {
                    if (node.Attributes["include_other_notes"] != null)
                    {
                        include_other_notes = Convert.ToBoolean(node.Attributes["include_other_notes"].Value);
                    }
                    else
                    {
                        include_other_notes = false;
                    }
                    if (node.Attributes["x"] != null)
                    {
                        x = Convert.ToDouble(node.Attributes["x"].Value);
                    }
                    else
                    {
                        x = 0;
                    }
                    if (node.Attributes["y"] != null)
                    {
                        y = Convert.ToDouble(node.Attributes["y"].Value);
                    }
                    else
                    {
                        y = 0;
                    }
                    if (node.Attributes["width"] != null)
                    {
                        width = Convert.ToDouble(node.Attributes["width"].Value);
                    }
                    else
                    {
                        width = 0;
                    }
                    if (node.Attributes["height"] != null)
                    {
                        height = Convert.ToDouble(node.Attributes["height"].Value);
                    }
                    else
                    {
                        height = 0;
                    }
                    if (node.Attributes["size"] != null)
                    {
                        font_size = Convert.ToDouble(node.Attributes["size"].Value);
                    }
                    else
                    {
                        font_size = 14;
                    }
                    if (node.Attributes["prefix"] != null)
                    {
                        prefix = node.Attributes["prefix"].Value;
                    }
                    else
                    {
                        prefix = "";
                    }
                    if (node.Attributes["suffix"] != null)
                    {
                        suffix = node.Attributes["suffix"].Value;
                    }
                    else
                    {
                        suffix = "";
                    }
                    if (node.Attributes["font"] != null)
                    {
                        font_family = node.Attributes["font"].Value;
                    }
                    else
                    {
                        font_family = "Arial";
                    }
                    if (node.Attributes["style"] != null)
                    {
                        font_style = node.Attributes["style"].Value;
                    }
                    else
                    {
                        font_style = "regular";
                    }
                    if (node.Attributes["align"] != null)
                    {
                        align = node.Attributes["align"].Value;
                    }
                    else
                    {
                        align = "left";
                    }
                    if (node.Attributes["color"] != null)
                    {
                        try {
                            color = ColorTranslator.FromHtml(node.Attributes["color"].Value);
                        } catch {
                            color = Color.Black;
                        }
                    }
                    else
                    {
                        color = Color.Black;
                    }

                    XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.WinAnsi, PdfFontEmbedding.Default);

                    XFontStyle style = XFontStyle.Regular;
                    switch (font_style.ToLower())
                    {
                    case "bold":
                        style = XFontStyle.Bold;
                        break;

                    case "bolditalic":
                        style = XFontStyle.BoldItalic;
                        break;

                    case "italic":
                        style = XFontStyle.Italic;
                        break;

                    case "strikeout":
                        style = XFontStyle.Strikeout;
                        break;

                    case "underline":
                        style = XFontStyle.Underline;
                        break;
                    }

                    XFont         font   = new XFont(font_family, font_size, style, options);
                    XStringFormat format = new XStringFormat();
                    switch (align.ToLower())
                    {
                    case "left":
                        format.Alignment = XStringAlignment.Near;
                        break;

                    case "center":
                        format.Alignment = XStringAlignment.Center;
                        break;

                    case "right":
                        format.Alignment = XStringAlignment.Far;
                        break;
                    }

                    prefix = System.Text.RegularExpressions.Regex.Unescape(prefix);
                    suffix = System.Text.RegularExpressions.Regex.Unescape(suffix);

                    switch (node.Name.ToLower())
                    {
                    case "cong_name":
                        this.gfx.DrawString(prefix + Form1.settings.cong_name + suffix, font, new XSolidBrush(XColor.FromArgb(color)), new XRect(x, y, width, height), format);
                        break;

                    case "map_name":
                        this.gfx.DrawString(prefix + Form1.map.name + suffix, font, new XSolidBrush(XColor.FromArgb(color)), new XRect(x, y, width, height), format);
                        break;

                    case "dnc_list":
                        if (include_other_notes && Form1.map.notes.Length > 0)
                        {
                            suffix += "\n" + Form1.map.notes;
                        }
                        this.tf.DrawString(prefix + generate_dnc_list(font, width) + suffix, font, new XSolidBrush(XColor.FromArgb(color)), new XRect(x, y, width, height), XStringFormats.TopLeft);
                        break;

                    case "other_notes":
                        this.tf.DrawString(prefix + Form1.map.notes + suffix, font, new XSolidBrush(XColor.FromArgb(color)), new XRect(x, y, width, height), XStringFormats.TopLeft);
                        break;

                    case "directions":
                        this.tf.DrawString(prefix + generate_directions(font, width) + suffix, font, new XSolidBrush(XColor.FromArgb(color)), new XRect(x, y, width, height), XStringFormats.TopLeft);
                        break;

                    case "text":
                        this.gfx.DrawString(node.InnerText, font, new XSolidBrush(XColor.FromArgb(color)), new XRect(x, y, width, height), format);
                        break;
                    }
                }
            }
        }
        public override int On進行描画()
        {
            if (!base.b活性化してない)
            {
                int num;
                if (base.b初めての進行描画)
                {
                    this.ct登場用 = new CCounter(0, 100, 5, TJAPlayer3.Timer);
                    this.actFI.tフェードイン開始();
                    base.eフェーズID = CStage.Eフェーズ.共通_フェードイン;
                    if (this.rResultSound != null)
                    {
                        this.rResultSound.t再生を開始する();
                    }
                    base.b初めての進行描画 = false;
                }
                this.bアニメが完了 = true;
                if (this.ct登場用.b進行中)
                {
                    this.ct登場用.t進行();
                    if (this.ct登場用.b終了値に達した)
                    {
                        this.ct登場用.t停止();
                    }
                    else
                    {
                        this.bアニメが完了 = false;
                    }
                }

                // 描画

                if (!b音声再生 && !TJAPlayer3.Skin.bgmリザルトイン音.b再生中)
                {
                    TJAPlayer3.Skin.bgmリザルト音.t再生する();
                    b音声再生 = true;
                }

                if (TJAPlayer3.Tx.Result_Background != null)
                {
                    TJAPlayer3.Tx.Result_Background[0].t2D描画(TJAPlayer3.app.Device, 0, 0);
                }

                if (TJAPlayer3.Tx.Result_Header != null)
                {
                    TJAPlayer3.Tx.Result_Header.t2D描画(TJAPlayer3.app.Device, 0, 0);
                }

                if (this.actParameterPanel.On進行描画() == 0)
                {
                    this.bアニメが完了 = false;
                }

                if (this.actSongBar.On進行描画() == 0)
                {
                    this.bアニメが完了 = false;
                }

                #region ネームプレート
                for (int i = 0; i < TJAPlayer3.ConfigIni.nPlayerCount; i++)
                {
                    TJAPlayer3.NamePlate.tNamePlateDraw(28, 621, i);
                }
                #endregion

                if (base.eフェーズID == CStage.Eフェーズ.共通_フェードイン)
                {
                    if (this.actFI.On進行描画() != 0)
                    {
                        base.eフェーズID = CStage.Eフェーズ.共通_通常状態;
                    }
                }
                else if ((base.eフェーズID == CStage.Eフェーズ.共通_フェードアウト))                         //&& ( this.actFO.On進行描画() != 0 ) )
                {
                    return((int)this.eフェードアウト完了時の戻り値);
                }

                #region [ #24609 2011.3.14 yyagi ランク更新or演奏型スキル更新時、リザルト画像をpngで保存する ]
                if (this.bアニメが完了 == true && this.bIsCheckedWhetherResultScreenShouldSaveOrNot == false &&               // #24609 2011.3.14 yyagi; to save result screen in case BestRank or HiSkill.
                    TJAPlayer3.ConfigIni.bScoreIniを出力する &&
                    TJAPlayer3.ConfigIni.bIsAutoResultCapture)                                                                      // #25399 2011.6.9 yyagi
                {
                    CheckAndSaveResultScreen(true);
                    this.bIsCheckedWhetherResultScreenShouldSaveOrNot = true;
                }
                #endregion

                // キー入力

                if (TJAPlayer3.act現在入力を占有中のプラグイン == null)
                {
                    if (base.eフェーズID == CStage.Eフェーズ.共通_通常状態)
                    {
                        if (TJAPlayer3.Input管理.Keyboard.bキーが押された((int)SlimDXKeys.Key.Escape))
                        {
                            TJAPlayer3.Skin.bgmリザルト音.t停止する();
                            TJAPlayer3.Skin.sound決定音.t再生する();
                            actFI.tフェードアウト開始();
                            base.eフェーズID         = CStage.Eフェーズ.共通_フェードアウト;
                            this.eフェードアウト完了時の戻り値 = E戻り値.完了;
                        }
                        if (((TJAPlayer3.Pad.b押されたDGB(Eパッド.CY) || TJAPlayer3.Pad.b押された(E楽器パート.DRUMS, Eパッド.RD)) || (TJAPlayer3.Pad.b押された(E楽器パート.DRUMS, Eパッド.LC) || (TJAPlayer3.Pad.b押されたDGB(Eパッド.LRed) || (TJAPlayer3.Pad.b押されたDGB(Eパッド.RRed) || TJAPlayer3.Input管理.Keyboard.bキーが押された((int)SlimDXKeys.Key.Return))))))
                        {
                            TJAPlayer3.Skin.sound決定音.t再生する();
                            actFI.tフェードアウト開始();

                            if (TJAPlayer3.stage選曲.n確定された曲の難易度 != (int)Difficulty.Dan && TJAPlayer3.stage選曲.n確定された曲の難易度 != (int)Difficulty.Tower)
                            {
                                if (nスコアランク != 0)
                                {
                                    if (TJAPlayer3.stage選曲.r確定されたスコア.譜面情報.nスコアランク[TJAPlayer3.stage選曲.n確定された曲の難易度] == 0)
                                    {
                                        TJAPlayer3.stage選曲.act曲リスト.ScoreRankCount[nスコアランク - 1] += 1;
                                    }
                                    else if (TJAPlayer3.stage選曲.r確定されたスコア.譜面情報.nスコアランク[TJAPlayer3.stage選曲.n確定された曲の難易度] < nスコアランク)
                                    {
                                        TJAPlayer3.stage選曲.act曲リスト.ScoreRankCount[nスコアランク - 1] += 1;
                                        TJAPlayer3.stage選曲.act曲リスト.ScoreRankCount[TJAPlayer3.stage選曲.r確定されたスコア.譜面情報.nスコアランク[TJAPlayer3.stage選曲.n確定された曲の難易度] - 1] -= 1;
                                    }
                                }

                                if (nクリア != 0)
                                {
                                    if (TJAPlayer3.stage選曲.r確定されたスコア.譜面情報.nクリア[TJAPlayer3.stage選曲.n確定された曲の難易度] == 0)
                                    {
                                        TJAPlayer3.stage選曲.act曲リスト.CrownCount[nクリア - 1] += 1;
                                    }
                                    else if (TJAPlayer3.stage選曲.r確定されたスコア.譜面情報.nクリア[TJAPlayer3.stage選曲.n確定された曲の難易度] < nクリア)
                                    {
                                        TJAPlayer3.stage選曲.act曲リスト.CrownCount[nクリア - 1] += 1;
                                        TJAPlayer3.stage選曲.act曲リスト.CrownCount[TJAPlayer3.stage選曲.r確定されたスコア.譜面情報.nクリア[TJAPlayer3.stage選曲.n確定された曲の難易度] - 1] -= 1;
                                    }
                                }
                            }

                            if (!b最近遊んだ曲追加済み)
                            {
                                #region [ 選曲画面の譜面情報の更新 ]
                                //---------------------
                                if (!TJAPlayer3.bコンパクトモード)
                                {
                                    if (TJAPlayer3.stage選曲.n確定された曲の難易度 != (int)Difficulty.Dan && TJAPlayer3.stage選曲.n確定された曲の難易度 != (int)Difficulty.Tower)
                                    {
                                        Cスコア cスコア = TJAPlayer3.stage選曲.r確定されたスコア;

                                        if (cスコア.譜面情報.nクリア[TJAPlayer3.stage選曲.n確定された曲の難易度] < nクリア)
                                        {
                                            cスコア.譜面情報.nクリア[TJAPlayer3.stage選曲.n確定された曲の難易度] = this.nクリア;
                                        }

                                        if (cスコア.譜面情報.nスコアランク[TJAPlayer3.stage選曲.n確定された曲の難易度] < nスコアランク)
                                        {
                                            cスコア.譜面情報.nスコアランク[TJAPlayer3.stage選曲.n確定された曲の難易度] = this.nスコアランク;
                                        }
                                    }
                                }
                                //---------------------
                                #endregion

                                foreach (var song in TJAPlayer3.Songs管理.list曲ルート)
                                {
                                    if (song.strジャンル == "最近遊んだ曲" && song.eノード種別 == C曲リストノード.Eノード種別.BOX)
                                    {
                                        song.list子リスト.Add(TJAPlayer3.stage選曲.r確定された曲.Clone());

                                        foreach (var song2 in song.list子リスト)
                                        {
                                            song2.r親ノード   = song;
                                            song2.strジャンル = "最近遊んだ曲";

                                            if (song2.eノード種別 != C曲リストノード.Eノード種別.BACKBOX)
                                            {
                                                song2.BackColor = ColorTranslator.FromHtml("#164748");
                                            }
                                        }

                                        if (song.list子リスト.Count >= 6)
                                        {
                                            song.list子リスト.RemoveAt(1);
                                        }
                                    }
                                }

                                b最近遊んだ曲追加済み = true;
                            }

                            if (TJAPlayer3.stage選曲.r現在選択中の曲.r親ノード != null)
                            {
                                TJAPlayer3.stage選曲.act曲リスト.tBOXを出る();
                            }
                            else
                            {
                                base.eフェーズID         = CStage.Eフェーズ.共通_フェードアウト;
                                this.eフェードアウト完了時の戻り値 = E戻り値.完了;
                                TJAPlayer3.Skin.bgmリザルト音.t停止する();
                                TJAPlayer3.Skin.sound決定音.t再生する();
                            }
                        }
                    }
                }
            }
            return(0);
        }
Пример #19
0
        private static Bitmap toBitmap(BitMatrix matrix, string color, string bgcolor)
        {
            int           width           = matrix.Width;
            int           height          = matrix.Height;
            Bitmap        bitmap          = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            Color         foregroundcolor = (color == null || color == "") ? ColorTranslator.FromHtml("#000000") : ColorTranslator.FromHtml(color);
            Color         backgroundcolor = (color == null || color == "") ? Color.Transparent : ColorTranslator.FromHtml(bgcolor);
            BarcodeWriter barcodeWriter   = new BarcodeWriter();

            barcodeWriter.Renderer = new ZXing.Rendering.BitmapRenderer {
                Background = backgroundcolor, Foreground = foregroundcolor
            };                                                                                                                         //设置颜色
            Bitmap map = barcodeWriter.Write(matrix);

            return(bitmap);
        }
Пример #20
0
        private void dataGridViewAllOrders_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            if (e.ListChangedType == ListChangedType.ItemChanged)
            {
                return;
            }

            for (int rowIdx = 0; rowIdx < this.dataGridViewAllOrders.Rows.Count; rowIdx++)
            {
                DataGridViewCell orderLineItemIdCell = this.dataGridViewAllOrders.Rows[rowIdx].Cells[OrderDgv_OrderLineItemIndex];
                if (orderLineItemIdCell.Value == null)
                {
                    continue;
                }

                String  orderLineItemId = orderLineItemIdCell.Value.ToString();
                DataRow dr = getEbayTransactionLocally(orderLineItemId);
                if (dr == null)
                {
                    continue;
                }

                String orderId  = StringUtil.GetSafeString(this.dataGridViewAllOrders.Rows[rowIdx].Cells[OrderDgv_OrderIdIndex].Value);
                bool   subtrans = false;
                if (orderId.IndexOf("-") < 0)
                {
                    // An order with multiple transactions.
                    bool imageSpecified = false;
                    if (rowIdx > 0)
                    {
                        String prevOrderId = StringUtil.GetSafeString(this.dataGridViewAllOrders.Rows[rowIdx - 1].Cells[OrderDgv_OrderIdIndex].Value);
                        if (prevOrderId == orderId)
                        {
                            this.dataGridViewAllOrders.Rows[rowIdx].Cells[OrderDgv_ImageIndex].Value = blankImage;
                            //this.dataGridViewAllOrders.Rows[rowIdx].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#DBADDA");
                            imageSpecified = true;
                            subtrans       = true;
                        }
                    }

                    if (!imageSpecified)
                    {
                        this.dataGridViewAllOrders.Rows[rowIdx].Cells[OrderDgv_ImageIndex].Value = minusImage;
                    }

                    if (subtrans)
                    {
                        this.dataGridViewAllOrders.Rows[rowIdx].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#DBADDA");
                    }
                    //subtrans = true;
                }
                else
                {
                    this.dataGridViewAllOrders.Rows[rowIdx].Cells[OrderDgv_ImageIndex].Value = normalImage;
                }

                //if (StringUtil.GetSafeBool(dr["IsSellerLeftFeedback"]))
                //    this.dataGridViewAllOrders.Rows[rowIdx].Cells[OrderDgv_SellerLeftFeedbackIndex].Value = yesImage;

                bool isShipped = StringUtil.GetSafeBool(dr["IsShipped"]);
                bool isPaid    = StringUtil.GetSafeBool(dr["IsPaid"]);

                // http://www.phpx.com/man/dhtmlcn/colors/colors.html
                if (isShipped == true && !subtrans)
                {
                    this.dataGridViewAllOrders.Rows[rowIdx].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#90EE90");
                }

                if (isPaid == false && !subtrans)
                {
                    this.dataGridViewAllOrders.Rows[rowIdx].DefaultCellStyle.BackColor = ColorTranslator.FromHtml("#808080");
                }
            }
        }
Пример #21
0
        public string ToRawSsa(string styleFormat)
        {
            var sb = new StringBuilder();

            sb.Append("Style: ");
            var format = styleFormat.ToLowerInvariant().Substring(8).Split(',');

            for (int i = 0; i < format.Length; i++)
            {
                string f = format[i].Trim();
                if (f == "name")
                {
                    sb.Append(Name);
                }
                else if (f == "fontname")
                {
                    sb.Append(FontName);
                }
                else if (f == "fontsize")
                {
                    sb.Append(FontSize.ToString(CultureInfo.InvariantCulture));
                }
                else if (f == "primarycolour")
                {
                    sb.Append(ColorTranslator.ToWin32(Primary));
                }
                else if (f == "secondarycolour")
                {
                    sb.Append(ColorTranslator.ToWin32(Secondary));
                }
                else if (f == "tertiarycolour")
                {
                    sb.Append(ColorTranslator.ToWin32(Tertiary));
                }
                else if (f == "backcolour")
                {
                    sb.Append(ColorTranslator.ToWin32(Background));
                }
                else if (f == "bold")
                {
                    sb.Append(BoolToRawSsa(Bold));
                }
                else if (f == "italic")
                {
                    sb.Append(BoolToRawSsa(Italic));
                }
                else if (f == "underline")
                {
                    sb.Append(BoolToRawSsa(Underline));
                }
                else if (f == "outline")
                {
                    sb.Append(ColorTranslator.ToWin32(Outline));
                }
                else if (f == "shadow")
                {
                    sb.Append(OutlineWidth.ToString(CultureInfo.InvariantCulture));
                }
                else if (f == "marginl")
                {
                    sb.Append(MarginLeft);
                }
                else if (f == "marginr")
                {
                    sb.Append(MarginRight);
                }
                else if (f == "marginv")
                {
                    sb.Append(MarginVertical);
                }
                else if (f == "borderstyle")
                {
                    sb.Append(BorderStyle);
                }
                else if (f == "encoding")
                {
                    sb.Append('1');
                }
                else if (f == "strikeout")
                {
                    sb.Append('0');
                }
                else if (f == "scalex")
                {
                    sb.Append(ScaleX.ToString(CultureInfo.InvariantCulture));
                }
                else if (f == "scaley")
                {
                    sb.Append(ScaleY.ToString(CultureInfo.InvariantCulture));
                }
                else if (f == "spacing")
                {
                    sb.Append(Spacing.ToString(CultureInfo.InvariantCulture));
                }
                else if (f == "angle")
                {
                    sb.Append(Angle.ToString(CultureInfo.InvariantCulture));
                }

                sb.Append(',');
            }

            var s = sb.ToString().Trim();

            return(s.Substring(0, s.Length - 1));
        }
Пример #22
0
        public Form1()
        {
            InitializeComponent();

            this.panel3.Padding = new Padding(50,20,50, 1);
            this.superAccelerator1.SetAccelerator(this.toolStripTabItem2, "R");
            this.gradientPanel1.Visible = false;
            this.richTextBox1.Visible = false;
            this.gridControl1.Visible = false;
            this.ribbonControlAdv1.SelectedTab = toolStripTabItem6;
            this.ribbonControlAdv1.ShowMinimizeButton = true;
            this.statusStripEx1.ContextMenuStrip = null;
            this.toolStripPanelItem24.BackColor = Color.FromArgb(205, 230, 247);
            this.toolStripButton35.BackColor = Color.FromArgb(205, 230, 247);
           
            // To host any .Net control into ToolStripEx, StatusStrip,
            // User can make use of ToolStripControlHost class
            // and host the control inside it and add the host
            // to item collection.
            this.treeViewAdv1.Style = TreeStyle.Metro;
            ToolStripControlHost host1 = new ToolStripControlHost(this.treeViewAdv1);
            this.toolStripEx25.Items.Add(host1);
            GridMetroColors theme = new GridMetroColors();
            theme.HeaderBottomBorderWeight = GridBottomBorderWeight.Thick;
            theme.HeaderBottomBorderColor = ColorTranslator.FromHtml("#217346");
            theme.HeaderColor.HoverColor = ColorTranslator.FromHtml("#9fd5b7");
            theme.HeaderTextColor.NormalTextColor = Color.Black;
            this.gridControl1.SetMetroStyle(theme);
            ToolStripControlHost host2 = new ToolStripControlHost(this.gridControl1);
            this.toolStripEx26.Items.Add(host2);
            ToolStripControlHost host3 = new ToolStripControlHost(this.panel1);
            this.panel1.Visible = false;
            this.toolStripSplitButton1.DropDown = new CustomDropdown(this.colorPickerUIAdv1);
            try
            {
                System.Drawing.Icon ico = new System.Drawing.Icon(GetIconFile(@"common\Images\Grid\Icon\sfgrid.ico"));
                this.Icon = ico;
            }
            catch { }


            foreach (ToolStripTabItem items in this.ribbonControlAdv1.Header.MainItems)
            {
                foreach (ToolStripEx item in items.Panel.Controls)
                {
                    item.LauncherClick += new EventHandler(item_LauncherClick);
                }
            }

            this.ribbonControlAdv1.QuickPanelVisible = true;
            this.HelpButton = false;
            this.ribbonControlAdv1.ShowRibbonDisplayOptionButton = false;
            this.WindowState = FormWindowState.Maximized;

            string path = Application.StartupPath.ToString() + @"..\..\..\Introduction.rtf";
            if (File.Exists(path))
                this.richTextBox2.LoadFile(path, RichTextBoxStreamType.RichText);

            foreach (ToolStripTabItem item in this.ribbonControlAdv1.Header.MainItems)
            {
                foreach (ToolStripEx toolstripex in item.Panel.Controls)
                {
                    toolstripex.AutoSize = true;
                    if (toolstripex.Text == "Labels")
                    {
                        toolstripex.Padding = new Padding(10, 0, 0, 0);
                    }
                }
            }

        }
Пример #23
0
        /// <summary>
        /// Color box to the right of the layer name when the layer is collapsed.
        /// </summary>
        private void DrawSmallColorBox(Graphics g, LegendLayer lyr, Rectangle bounds, int top, int left)
        {
            if (lyr.Expanded) return;

            lyr.SmallIconWasDrawn = true;

            // drawing category symbol
            var hdc = g.GetHdc();
            var hdcInt = hdc.ToInt32();
            var clr = (lyr.Handle == Legend.SelectedLayerHandle && bounds.Width > 25)
                          ? Legend.SelectionColor
                          : Legend.BackColor;

            var backColor = Convert.ToUInt32(ColorTranslator.ToOle(clr));

            var sf = Legend.AxMap.get_GetObject(lyr.Handle) as Shapefile;

            if (sf != null)
            {
                if (lyr.LegendLayerType == LegendLayerType.PointShapefile)
                {
                    sf.DefaultDrawingOptions.DrawPoint(
                        hdcInt,
                        left,
                        top,
                        Constants.IconSize,
                        Constants.IconSize,
                        backColor);
                }
                else if (lyr.LegendLayerType == LegendLayerType.LineShapefile)
                {
                    sf.DefaultDrawingOptions.DrawLine(
                        hdcInt,
                        left,
                        top,
                        Constants.IconSize - 1,
                        Constants.IconSize - 1,
                        false,
                        Constants.IconSize,
                        Constants.IconSize,
                        backColor);
                }
                else if (lyr.LegendLayerType == LegendLayerType.PolygonShapefile)
                {
                    sf.DefaultDrawingOptions.DrawRectangle(
                        hdcInt,
                        left,
                        top,
                        Constants.IconSize - 1,
                        Constants.IconSize - 1,
                        false,
                        Constants.IconSize,
                        Constants.IconSize,
                        backColor);
                }
            }

            g.ReleaseHdc(hdc);

            lyr.Elements.Add(
                LayerElementType.ColorBox,
                new Rectangle(left, top, Constants.IconSize, Constants.IconSize));
        }
Пример #24
0
        public void GenerateImage()
        {
            // Create a new 32-bit bitmap image.
            Bitmap bitmap = new Bitmap(this.width, this.height, PixelFormat.Format32bppArgb);

            // Create a graphics object for drawing.
            Graphics g = Graphics.FromImage(bitmap);

            g.PageUnit      = GraphicsUnit.Pixel;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Rectangle rect = new Rectangle(0, 0, this.width, this.height);

            // Fill in the background.
            HatchBrush hatchBrush = new HatchBrush(HatchStyle.Shingle, ColorTranslator.FromHtml("#fff"), ColorTranslator.FromHtml("#fff"));

            g.FillRectangle(hatchBrush, rect);

            // Set up the text font.
            SizeF size;
            float fontSize = rect.Height + 1;
            Font  font;

            // Adjust the font size until the text fits within the image.
            do
            {
                fontSize--;
                font = new Font(this.fontFamily.Name, fontSize, GraphicsUnit.Pixel);
                size = g.MeasureString(this.text, font);
            } while (size.Width > rect.Width);

            // Set up the text format.
            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            // Create a path using the text and warp it randomly.
            GraphicsPath path = new GraphicsPath();

            path.AddString(this.text, font.FontFamily, (int)font.Style, font.Size, rect, format);
            float v = 4F;

            PointF[] points =
            {
                new PointF(this.random.Next(rect.Width) / v,              this.random.Next(rect.Height) / v),
                new PointF(rect.Width - this.random.Next(rect.Width) / v, this.random.Next(rect.Height) / v),
                new PointF(this.random.Next(rect.Width) / v,              rect.Height - this.random.Next(rect.Height) / v),
                new PointF(rect.Width - this.random.Next(rect.Width) / v, rect.Height - this.random.Next(rect.Height) / v)
            };
            Matrix matrix = new Matrix();

            matrix.Translate(0F, 0F);
            path.Warp(points, rect, matrix, WarpMode.Perspective, 0F);

            // Draw the text.
            hatchBrush = new HatchBrush(HatchStyle.Shingle, ColorTranslator.FromHtml("#ff6801"), ColorTranslator.FromHtml("#ff6801"));
            g.FillPath(hatchBrush, path);

            // Add some random noise.
            int m = Math.Max(rect.Width, rect.Height);

            for (int i = 0; i < (int)(rect.Width * rect.Height / 30F); i++)
            {
                int x = this.random.Next(rect.Width);
                int y = this.random.Next(rect.Height);
                int w = this.random.Next(m / 50);
                int h = this.random.Next(m / 50);
                g.FillEllipse(hatchBrush, x, y, w, h);
            }

            // Clean up.
            font.Dispose();
            hatchBrush.Dispose();
            g.Dispose();

            // Set the image.
            this.image = bitmap;
        }
Пример #25
0
        private static void LoadStylesFromTimedText10(Subtitle subtitle, string title, string header, string headerNoStyles, StringBuilder sb)
        {
            try
            {
                var lines = new List <string>();
                foreach (string s in subtitle.Header.Replace(Environment.NewLine, "\n").Split('\n'))
                {
                    lines.Add(s);
                }
                var tt  = new TimedText10();
                var sub = new Subtitle();
                tt.LoadSubtitle(sub, lines, string.Empty);

                var xml = new XmlDocument();
                xml.LoadXml(subtitle.Header);
                var nsmgr = new XmlNamespaceManager(xml.NameTable);
                nsmgr.AddNamespace("ttml", "http://www.w3.org/ns/ttml");
                XmlNode head          = xml.DocumentElement.SelectSingleNode("ttml:head", nsmgr);
                int     stylexmlCount = 0;
                var     ttStyles      = new StringBuilder();
                foreach (XmlNode node in head.SelectNodes("//ttml:style", nsmgr))
                {
                    string name = null;
                    if (node.Attributes["xml:id"] != null)
                    {
                        name = node.Attributes["xml:id"].Value;
                    }
                    else if (node.Attributes["id"] != null)
                    {
                        name = node.Attributes["id"].Value;
                    }
                    if (name != null)
                    {
                        stylexmlCount++;

                        string fontFamily = "Arial";
                        if (node.Attributes["tts:fontFamily"] != null)
                        {
                            fontFamily = node.Attributes["tts:fontFamily"].Value;
                        }

                        string fontWeight = "normal";
                        if (node.Attributes["tts:fontWeight"] != null)
                        {
                            fontWeight = node.Attributes["tts:fontWeight"].Value;
                        }

                        string fontStyle = "normal";
                        if (node.Attributes["tts:fontStyle"] != null)
                        {
                            fontStyle = node.Attributes["tts:fontStyle"].Value;
                        }

                        string color = "#ffffff";
                        if (node.Attributes["tts:color"] != null)
                        {
                            color = node.Attributes["tts:color"].Value.Trim();
                        }
                        Color c = Color.White;
                        try
                        {
                            if (color.StartsWith("rgb(", StringComparison.Ordinal))
                            {
                                string[] arr = color.Remove(0, 4).TrimEnd(')').Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                                c = Color.FromArgb(int.Parse(arr[0]), int.Parse(arr[1]), int.Parse(arr[2]));
                            }
                            else
                            {
                                c = ColorTranslator.FromHtml(color);
                            }
                        }
                        catch
                        {
                        }

                        string fontSize = "20";
                        if (node.Attributes["tts:fontSize"] != null)
                        {
                            fontSize = node.Attributes["tts:fontSize"].Value.Replace("px", string.Empty).Replace("em", string.Empty);
                        }
                        int fSize;
                        if (!int.TryParse(fontSize, out fSize))
                        {
                            fSize = 20;
                        }

                        const string styleFormat = "Style: {0},{1},{2},{3},65535,65535,-2147483640,-1,0,1,3,0,2,10,10,10,0,1";

                        ttStyles.AppendLine(string.Format(styleFormat, name, fontFamily, fSize, c.ToArgb()));
                    }
                }

                if (stylexmlCount > 0)
                {
                    sb.AppendLine(string.Format(headerNoStyles, title, ttStyles));
                    subtitle.Header = sb.ToString();
                }
                else
                {
                    sb.AppendLine(string.Format(header, title));
                }
            }
            catch
            {
                sb.AppendLine(string.Format(header, title));
            }
        }
Пример #26
0
        //BACKGROUNDWORKER


        private void  ExtractData()
        {
            System.Data.DataTable data = new System.Data.DataTable();

            Excel._Worksheet objSheet;
            objSheet = Globals.ThisAddIn.Application.ActiveSheet;

            string invoice    = "";
            string valToCell  = "";
            string itemFilter = "";
            string selection  = "";
            string itemId     = Convert.ToString(CboItemlist.SelectedValue);

            //ALL CHECKED
            if (!checkTodos.Checked)
            {
                itemFilter    = " AND LineItem.ItemID = '" + itemId + "' ";
                selection     = itemId;
                objSheet.Name = "SALDO DE CxC " + selection;
            }
            else
            {
                selection     = "TODOS";
                objSheet.Name = "SALDO DE CxC " + selection;
            }



            try
            {
                //Report to BackgroundWorker
                percentage = 10 * 100 / 100;
                bgw.ReportProgress(percentage, 10);

                //STAR BD CONNETION
                dbConn.StartConn();

                if (dbConn.StartConn().State == System.Data.ConnectionState.Open)
                {
                    data.Clear();

                    string query = "SELECT DISTINCT " +
                                   " Customers.Customer_Bill_Name, " +
                                   " JrnlHdr.Reference, " +
                                   " JrnlHdr.TransactionDate, " +
                                   " sum(ABS(JrnlRow.Amount)) as Amount, " +
                                   " sum(JrnlHdr.AmountPaid) as Paid,  " +
                                   " sum(JrnlHdr.MainAmount) as InvoiceAmount" +
                                   " FROM JrnlHdr " +
                                   " INNER JOIN JrnlRow ON JrnlHdr.PostOrder = JrnlRow.PostOrder " +
                                   " INNER JOIN LineItem ON LineItem.ItemRecordNumber = JrnlRow.ItemRecordNumber " +
                                   " INNER JOIN Customers ON Customers.CustomerRecordNumber = JrnlRow.CustomerRecordNumber " +
                                   " WHERE JrnlHdr.JrnlKey_Journal = '3' " +
                                   " AND JrnlHdr.MainAmount > ABS(AmountPaid) " +
                                   " AND JrnlRow.RowType = '0' " +
                                   itemFilter +
                                   " Group by TransactionDate , Customer_Bill_Name, Reference" +
                                   " Order by Customers.Customer_Bill_Name;";


                    //Report to BackgroundWorker
                    percentage = 20 * 100 / 100;
                    bgw.ReportProgress(percentage, 20);

                    //Start query to DB
                    objSheet.Range[objSheet.Cells[1, 1], objSheet.Cells[9999, 10]].Clear();

                    dbConn.Query(query).Fill(data);


                    //Report to BackgroundWorker
                    percentage = 100 * 100 / 100;
                    bgw.ReportProgress(percentage, 100);


                    if (data.Rows.Count > 0)
                    {
                        int i = 0;
                        int n = i;

                        //INI TABLE STYLING

                        //COLOR
                        objSheet.Range[objSheet.Cells[1, 1], objSheet.Cells[data.Rows.Count + 5, 10]].Interior.Color = ColorTranslator.ToOle(Color.White);
                        objSheet.Range[objSheet.Cells[6, 4], objSheet.Cells[data.Rows.Count + 5, 10]].Interior.Color = ColorTranslator.ToOle(Color.WhiteSmoke);
                        objSheet.Range[objSheet.Cells[6, 1], objSheet.Cells[data.Rows.Count + 5, 4]].Interior.Color  = ColorTranslator.ToOle(Color.LemonChiffon);
                        objSheet.Range[objSheet.Cells[1, 1], objSheet.Cells[1, 10]].Interior.Color = ColorTranslator.ToOle(Color.DarkSeaGreen);
                        objSheet.Cells[3, 1].Interior.Color = ColorTranslator.ToOle(Color.DarkSeaGreen);
                        objSheet.Cells[3, 2].Interior.Color = ColorTranslator.ToOle(Color.WhiteSmoke);
                        objSheet.Range[objSheet.Cells[5, 1], objSheet.Cells[5, 10]].Interior.Color = ColorTranslator.ToOle(Color.DarkSeaGreen);

                        //FONT BOLD
                        objSheet.Range[objSheet.Cells[1, 1], objSheet.Cells[1, 10]].EntireRow.Font.Bold = true;
                        objSheet.Cells[3, 1].EntireRow.Font.Bold = true;
                        objSheet.Range[objSheet.Cells[5, 1], objSheet.Cells[5, 10]].EntireRow.Font.Bold = true;

                        //MERGED CELLS
                        objSheet.Range[objSheet.Cells[1, 1], objSheet.Cells[1, 10]].Merge();

                        //TEXT ALIGN
                        objSheet.get_Range("A1", "A1").Style.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;


                        //BORDER
                        objSheet.Range[objSheet.Cells[1, 1], objSheet.Cells[data.Rows.Count + 5, 10]].Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
                        objSheet.Range[objSheet.Cells[1, 1], objSheet.Cells[data.Rows.Count + 5, 10]].Borders.Weight    = Excel.XlBorderWeight.xlMedium;
                        objSheet.Range[objSheet.Cells[1, 1], objSheet.Cells[data.Rows.Count + 5, 10]].Borders.Color     = ColorTranslator.ToOle(Color.White);

                        //CURRENCY CELLS
                        objSheet.Range[objSheet.Cells[5, 4], objSheet.Cells[data.Rows.Count + 5, 10]].NumberFormat = "#,###.00";

                        //FILTER
                        objSheet.Range[objSheet.Cells[5, 1], objSheet.Cells[5, 10]].Autofilter();

                        //END TABLE STYLING


                        //TABLE HEADER
                        objSheet.Cells[1, 1]  = "SALDO DE CxC POR ITEM ID";
                        objSheet.Cells[3, 1]  = "Selección";
                        objSheet.Cells[3, 2]  = selection;
                        objSheet.Cells[5, 1]  = "Customer";
                        objSheet.Cells[5, 2]  = "Invoice #";
                        objSheet.Cells[5, 3]  = "Date";
                        objSheet.Cells[5, 4]  = "Status";
                        objSheet.Cells[5, 5]  = "0-30";
                        objSheet.Cells[5, 6]  = "31-60";
                        objSheet.Cells[5, 7]  = "61-90";
                        objSheet.Cells[5, 8]  = "91-120";
                        objSheet.Cells[5, 9]  = "120+";
                        objSheet.Cells[5, 10] = "Total";

                        //WORKSHEET NAME
                        objSheet.Name = "SALDO DE CxC " + selection;

                        while (i < data.Rows.Count)
                        {
                            if (data.Rows[i].ItemArray[0] != null)
                            {
                                string dateTrx = data.Rows[i].ItemArray[2].ToString(); //Transaction Date



                                double days = (DateTime.Today - Convert.ToDateTime(dateTrx)).TotalDays; //Days Expired


                                if (invoice != data.Rows[i].ItemArray[0].ToString())
                                {
                                    objSheet.Cells[i + 6, 2] = data.Rows[i].ItemArray[1].ToString(); //Invoice Number
                                    invoice = data.Rows[i].ItemArray[1].ToString();

                                    n = i;
                                }

                                objSheet.Cells[n + 6, 1] = data.Rows[i].ItemArray[0].ToString();               //Customers
                                objSheet.Cells[n + 6, 3] = Convert.ToDateTime(dateTrx).ToString("yyyy-MM-dd"); //Transaction Date


                                //Report to BackgroundWorker
                                percentage = i * 100 / data.Rows.Count;
                                bgw.ReportProgress(percentage, i);



                                if (Convert.ToDouble(data.Rows[i].ItemArray[4]) == 0.00)
                                {
                                    objSheet.Cells[n + 6, 4] = "Pendiente de pago"; //Status
                                    objSheet.Cells[n + 6, 4].Interior.Color = ColorTranslator.ToOle(Color.LightSalmon);
                                }
                                else
                                {
                                    objSheet.Cells[n + 6, 4] = "Parcialmente pagado"; //Status
                                    objSheet.Cells[n + 6, 4].Interior.Color = ColorTranslator.ToOle(Color.LightGreen);
                                }



                                //EXPIRE DAY
                                if (days <= 30)
                                {
                                    valToCell = SumValue((objSheet.Cells[n + 6, 5] as Excel.Range).Value, data.Rows[i].ItemArray[3].ToString());

                                    objSheet.Cells[n + 6, 5] = valToCell;
                                }
                                if (days > 30 & days <= 60)
                                {
                                    valToCell = SumValue((objSheet.Cells[n + 6, 6] as Excel.Range).Value, data.Rows[i].ItemArray[3].ToString());

                                    objSheet.Cells[n + 6, 6] = valToCell;
                                }
                                if (days > 60 & days <= 90)
                                {
                                    valToCell = SumValue((objSheet.Cells[n + 6, 7] as Excel.Range).Value, data.Rows[i].ItemArray[3].ToString());

                                    objSheet.Cells[n + 6, 7] = valToCell;
                                }
                                if (days > 90 & days <= 120)
                                {
                                    valToCell = SumValue((objSheet.Cells[n + 6, 8] as Excel.Range).Value, data.Rows[i].ItemArray[3].ToString());

                                    objSheet.Cells[n + 6, 8] = valToCell;
                                }

                                if (days > 120)
                                {
                                    valToCell = SumValue((objSheet.Cells[n + 6, 9] as Excel.Range).Value, data.Rows[i].ItemArray[3].ToString());

                                    objSheet.Cells[n + 6, 9] = valToCell;
                                }


                                objSheet.Cells[n + 6, 10].Formula = "=Sum(E" + (n + 6) + ":I" + (n + 6) + ")"; //Total


                                i++;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("No existen datos que procesar para esta seleccion");
                    }

                    //elimina lineas en blanco
                    Excel.Range range    = objSheet.UsedRange;
                    int         rowcount = range.Rows.Count;
                    for (int l = 6; l < rowcount; l++)
                    {
                        Excel.Range rg = objSheet.get_Range("A" + l.ToString());
                        if (Convert.ToString(rg.Value2) == null)
                        {
                            ((Excel.Range)objSheet.Range["A" + l.ToString(), "Z" + l.ToString()]).EntireRow.Delete(null);
                            l--;
                            rowcount--;
                        }
                    }



                    //ACOMODA LAS CELDAS
                    objSheet.Columns.AutoFit();

                    //Close ProgresssBar
                    proBar.FinishProcess();
                }
            }
            catch (Exception theException)
            {
                String errorMessage;
                errorMessage = "Error: ";
                errorMessage = String.Concat(errorMessage, theException.Message);
                errorMessage = String.Concat(errorMessage, " Line: ");
                errorMessage = String.Concat(errorMessage, theException.Source);

                MessageBox.Show(errorMessage, "Error");
            }
        }
 public LollipopLabel()
 {
     this.Font = font.Roboto_Medium10;
     ForeColor = ColorTranslator.FromHtml("#999999");
     BackColor = Color.Transparent;
 }
Пример #28
0
        public BannedWindow()
        {
            InitializeComponent();

            visualLabel1.BackColor = ColorTranslator.FromHtml("#f4765d");
        }
 /// <summary>
 /// Overrides the paint.
 /// </summary>
 /// <param name="e">A <see cref="PaintEventArgs"/> value.</param>
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, ColorTranslator.FromHtml("#7A7A7A"), ButtonBorderStyle.Solid);
 }
Пример #30
0
        private void themeComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            this.BeginUpdate();
            this.themeComboBox.ThemeName      = this.themeComboBox.SelectedValue.ToString();
            this.tokenComboBox.ThemeName      = this.themeComboBox.SelectedValue.ToString();
            this.SearchTextComboBox.ThemeName = this.themeComboBox.SelectedValue.ToString();
            this.selectAll.ThemeName          = this.themeComboBox.SelectedValue.ToString();
            this.toolTip.ThemeName            = this.themeComboBox.SelectedValue.ToString();
            this.delimiterChar.ThemeName      = this.themeComboBox.SelectedValue.ToString();
            this.waterMark.ThemeName          = this.themeComboBox.SelectedValue.ToString();
            switch (this.themeComboBox.SelectedValue.ToString())
            {
            case "Office2016Black":
                this.Style.TitleBar.BackColor                    = Color.FromArgb(38, 38, 38);
                this.Style.TitleBar.CloseButtonForeColor         = ColorTranslator.FromHtml("#f0f0f0");
                this.Style.TitleBar.CloseButtonHoverBackColor    = ColorTranslator.FromHtml("#d4d4d4");
                this.Style.TitleBar.MinimizeButtonForeColor      = ColorTranslator.FromHtml("#f0f0f0");
                this.Style.TitleBar.MinimizeButtonHoverBackColor = ColorTranslator.FromHtml("#d4d4d4");
                this.BackColor                = ColorTranslator.FromHtml("#444444");
                this.label1.BackColor         = ColorTranslator.FromHtml("#444444");
                this.label2.BackColor         = ColorTranslator.FromHtml("#444444");
                this.label3.BackColor         = ColorTranslator.FromHtml("#444444");
                this.label4.BackColor         = ColorTranslator.FromHtml("#444444");
                this.label5.BackColor         = ColorTranslator.FromHtml("#444444");
                this.label6.BackColor         = ColorTranslator.FromHtml("#444444");
                this.label7.BackColor         = ColorTranslator.FromHtml("#444444");
                this.label8.BackColor         = ColorTranslator.FromHtml("#444444");
                this.customTextBox.BackColor  = ColorTranslator.FromHtml("#444444");
                this.Style.TitleBar.ForeColor = ColorTranslator.FromHtml("#d3d3d3");
                this.label1.ForeColor         = ColorTranslator.FromHtml("#d3d3d3");
                this.label2.ForeColor         = ColorTranslator.FromHtml("#d3d3d3");
                this.label3.ForeColor         = ColorTranslator.FromHtml("#d3d3d3");
                this.label4.ForeColor         = ColorTranslator.FromHtml("#d3d3d3");
                this.label5.ForeColor         = ColorTranslator.FromHtml("#d3d3d3");
                this.label6.ForeColor         = ColorTranslator.FromHtml("#d3d3d3");
                this.label7.ForeColor         = ColorTranslator.FromHtml("#d3d3d3");
                this.label8.ForeColor         = ColorTranslator.FromHtml("#d3d3d3");
                this.customTextBox.ForeColor  = ColorTranslator.FromHtml("#d3d3d3");
#if NETCORE
                this.customTextBox.pictureBox.Image = Image.FromFile(@"../../../Icon/Search_Black.png");
#else
                this.customTextBox.pictureBox.Image = Image.FromFile(@"../../Icon/Search_Black.png");
#endif

                break;

            case "Office2016DarkGray":
                this.BackColor = ColorTranslator.FromHtml("#d4d4d4");

                this.Style.TitleBar.CloseButtonForeColor         = ColorTranslator.FromHtml("#f0f0f0");
                this.Style.TitleBar.CloseButtonHoverBackColor    = ColorTranslator.FromHtml("#d4d4d4");
                this.Style.TitleBar.MinimizeButtonForeColor      = ColorTranslator.FromHtml("#f0f0f0");
                this.Style.TitleBar.MinimizeButtonHoverBackColor = ColorTranslator.FromHtml("#d4d4d4");
                this.Style.TitleBar.BackColor = Color.FromArgb(102, 102, 102);
                this.label1.BackColor         = ColorTranslator.FromHtml("#d4d4d4");
                this.label2.BackColor         = ColorTranslator.FromHtml("#d4d4d4");
                this.label3.BackColor         = ColorTranslator.FromHtml("#d4d4d4");
                this.label4.BackColor         = ColorTranslator.FromHtml("#d4d4d4");
                this.label5.BackColor         = ColorTranslator.FromHtml("#d4d4d4");
                this.label6.BackColor         = ColorTranslator.FromHtml("#d4d4d4");
                this.label7.BackColor         = ColorTranslator.FromHtml("#d4d4d4");
                this.label8.BackColor         = ColorTranslator.FromHtml("#d4d4d4");
                this.customTextBox.BackColor  = ColorTranslator.FromHtml("#d4d4d4");
                this.Style.TitleBar.ForeColor = Color.FromArgb(240, 240, 240);
                this.label1.ForeColor         = ColorTranslator.FromHtml("#262626");
                this.label2.ForeColor         = ColorTranslator.FromHtml("#262626");
                this.label3.ForeColor         = ColorTranslator.FromHtml("#262626");
                this.label4.ForeColor         = ColorTranslator.FromHtml("#262626");
                this.label5.ForeColor         = ColorTranslator.FromHtml("#262626");
                this.label6.ForeColor         = ColorTranslator.FromHtml("#262626");
                this.label7.ForeColor         = ColorTranslator.FromHtml("#262626");
                this.label8.ForeColor         = ColorTranslator.FromHtml("#262626");
                this.customTextBox.ForeColor  = ColorTranslator.FromHtml("#262626");
#if NETCORE
                this.customTextBox.pictureBox.Image = Image.FromFile(@"../../../Icon/search_DarkGray.png");
#else
                this.customTextBox.pictureBox.Image = Image.FromFile(@"../../Icon/search_DarkGray.png");
#endif

                break;

            default:
                this.BackColor = ColorTranslator.FromHtml("#FFFFFF");
                this.Style.TitleBar.BackColor                 = Color.FromArgb(242, 242, 242);
                this.Style.TitleBar.CloseButtonForeColor      = Color.FromArgb(51, 51, 51);
                this.Style.TitleBar.MinimizeButtonForeColor   = Color.FromArgb(51, 51, 51);
                this.Style.TitleBar.CloseButtonHoverBackColor = this.Style.TitleBar.MinimizeButtonHoverBackColor;
                this.Style.TitleBar.CloseButtonHoverForeColor = this.Style.TitleBar.MinimizeButtonHoverForeColor;
                this.label1.BackColor        = ColorTranslator.FromHtml("#FFFFFF");
                this.label2.BackColor        = ColorTranslator.FromHtml("#FFFFFF");
                this.label3.BackColor        = ColorTranslator.FromHtml("#FFFFFF");
                this.label4.BackColor        = ColorTranslator.FromHtml("#FFFFFF");
                this.label5.BackColor        = ColorTranslator.FromHtml("#FFFFFF");
                this.label6.BackColor        = ColorTranslator.FromHtml("#FFFFFF");
                this.label7.BackColor        = ColorTranslator.FromHtml("#FFFFFF");
                this.label8.BackColor        = ColorTranslator.FromHtml("#FFFFFF");
                this.customTextBox.BackColor = ColorTranslator.FromHtml("#FFFFFF");

                this.Style.TitleBar.ForeColor = ColorTranslator.FromHtml("#444444");
                this.label1.ForeColor         = ColorTranslator.FromHtml("#444444");
                this.label2.ForeColor         = ColorTranslator.FromHtml("#444444");
                this.label3.ForeColor         = ColorTranslator.FromHtml("#444444");
                this.label4.ForeColor         = ColorTranslator.FromHtml("#444444");
                this.label5.ForeColor         = ColorTranslator.FromHtml("#444444");
                this.label6.ForeColor         = ColorTranslator.FromHtml("#444444");
                this.label7.ForeColor         = ColorTranslator.FromHtml("#444444");
                this.label8.ForeColor         = ColorTranslator.FromHtml("#444444");
                this.customTextBox.ForeColor  = ColorTranslator.FromHtml("#444444");
#if NETCORE
                this.customTextBox.pictureBox.Image = Image.FromFile(@"../../../Icon/search_Colorful.png");
#else
                this.customTextBox.pictureBox.Image = Image.FromFile(@"../../Icon/search_Colorful.png");
#endif

                break;
            }

            this.EndUpdate();
        }