コード例 #1
0
ファイル: CommandDialog.cs プロジェクト: divyang4481/lextudio
 public CommandDialog()
 {
     // This call is required by the Windows Form Designer.
     InitializeComponent();
     mCommandLinks = new List<CommandLink>();
     mSelectedCommandLink = null;
     this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
     mShowCancelButton = true;
     this.CancelButton = btnCancel;
 }
コード例 #2
0
ファイル: CommandPool.cs プロジェクト: rebider/AutoCSer
 /// <summary>
 /// 新建客户端命令池
 /// </summary>
 /// <param name="currentIndex">当前空闲命令位置</param>
 /// <returns></returns>
 private int create(int currentIndex)
 {
     if (bitSize == maxArrayBitSize)
     {
         if (arrayCount == arrays.Length)
         {
             if (arrayCount == 1 << (Server.CommandIndexBits - maxArrayBitSize))
             {
                 freeIndex = currentIndex;
                 if (isErrorLog == 0)
                 {
                     isErrorLog = 1;
                     log.Add(LogType.Error, "TCP 客户端活动会话数量过多");
                 }
                 return(0);
             }
             arrays = arrays.copyNew(arrayCount << 1);
         }
         int           index = 1 << maxArrayBitSize;
         CommandLink[] array = new CommandLink[index];
         do
         {
             array[index - 1].Next = commandCount + index;
         }while (--index != 0);
         arrays[arrayCount++] = array;
         while (System.Threading.Interlocked.CompareExchange(ref freeEndIndexLock, 1, 0) != 0)
         {
             AutoCSer.Threading.ThreadYield.YieldOnly();
         }
         arrays[freeEndIndex >> bitSize][freeEndIndex & arraySizeAnd].Next = commandCount;
         freeEndIndex = (commandCount += 1 << maxArrayBitSize) - 1;
         System.Threading.Interlocked.Exchange(ref freeEndIndexLock, 0);
     }
     else
     {
         CommandLink[] array = new CommandLink[1 << ++bitSize];
         for (int index = commandCount, endIndex = commandCount << 1; index != endIndex; ++index)
         {
             array[index].Next = index + 1;
         }
         while (System.Threading.Interlocked.CompareExchange(ref freeEndIndexLock, 1, 0) != 0)
         {
             AutoCSer.Threading.ThreadYield.YieldOnly();
         }
         Array.CopyTo(array, 0);
         arrays[0] = Array = array;
         array[freeEndIndex].Next = commandCount;
         freeEndIndex             = arraySizeAnd = (commandCount <<= 1) - 1;
         System.Threading.Interlocked.Exchange(ref freeEndIndexLock, 0);
     }
     freeIndex = (currentIndex < (1 << maxArrayBitSize) ? Array : pushArray)[currentIndex & arraySizeAnd].Next;
     return(currentIndex);
 }
コード例 #3
0
        private CommandLink CreateResetButton(ResetMode mode)
        {
            string text = string.Empty;
            string desc = string.Empty;

            switch (mode)
            {
            case ResetMode.Soft:
                text = Resources.StrSoft;
                desc = Resources.TipSoftReset;
                break;

            case ResetMode.Mixed:
                text = Resources.StrMixed;
                desc = Resources.TipMixedReset;
                break;

            case ResetMode.Hard:
                text = Resources.StrHard;
                desc = Resources.TipHardReset;
                break;

            case ResetMode.Merge:
                text = Resources.StrMerge;
                desc = Resources.TipMergeReset;
                break;

            case ResetMode.Keep:
                text = Resources.StrKeep;
                desc = Resources.TipKeepReset;
                break;

            default:
                throw new NotSupportedException();
            }

            var btn = new CommandLink()
            {
                Size        = new Size(319, 66),
                Text        = text,
                Description = desc,
                Tag         = mode,
            };

            btn.Click += (s, e) =>
            {
                ResetMode = (ResetMode)((Control)s).Tag;
                ClickOk();
            };

            return(btn);
        }
コード例 #4
0
ファイル: Entity.cs プロジェクト: schmittens/Lemma
 public void LinkedCommandCall(CommandLink link)
 {
     if (link.LinkedTargetCmd != null)
     {
         link.LinkedTargetCmd.Execute();
     }
     else if (link.TargetEntity.Target != null)
     {
         Command destCommand = link.TargetEntity.Target.getCommand(link.TargetCommand);
         if (destCommand != null)
         {
             link.LinkedTargetCmd = destCommand;
             destCommand.Execute();
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// 新建客户端命令池
 /// </summary>
 /// <param name="currentIndex">当前空闲命令位置</param>
 /// <returns></returns>
 private int create(int currentIndex)
 {
     if (bitSize == maxArrayBitSize)
     {
         if (arrayCount == arrays.Length)
         {
             if (arrayCount == 1 << (Server.CommandIndexBits - maxArrayBitSize))
             {
                 freeIndex = currentIndex;
                 if (isErrorLog == 0)
                 {
                     isErrorLog = 1;
                     client.Log.Error("TCP 客户端活动会话数量过多", LogLevel.Error | LogLevel.AutoCSer);
                 }
                 return(0);
             }
             arrays = arrays.copyNew(arrayCount << 1);
         }
         int           index = 1 << maxArrayBitSize;
         CommandLink[] array = new CommandLink[index];
         do
         {
             array[index - 1].Next = commandCount + index;
         }while (--index != 0);
         arrays[arrayCount++] = array;
         freeEndIndexLock.Enter();
         arrays[freeEndIndex >> bitSize][freeEndIndex & arraySizeAnd].Next = commandCount;
         freeEndIndex = (commandCount += 1 << maxArrayBitSize) - 1;
         freeEndIndexLock.Exit();
     }
     else
     {
         CommandLink[] array = new CommandLink[1 << ++bitSize];
         for (int index = commandCount, endIndex = commandCount << 1; index != endIndex; ++index)
         {
             array[index].Next = index + 1;
         }
         freeEndIndexLock.Enter();
         Array.CopyTo(array, 0);
         arrays[0] = Array = array;
         array[freeEndIndex].Next = commandCount;
         freeEndIndex             = arraySizeAnd = (commandCount <<= 1) - 1;
         freeEndIndexLock.Exit();
     }
     freeIndex = (currentIndex < (1 << maxArrayBitSize) ? Array : pushArray)[currentIndex & arraySizeAnd].Next;
     return(currentIndex);
 }
コード例 #6
0
ファイル: Entity.cs プロジェクト: schmittens/Lemma
        public void RemoveCommand(string name)
        {
            try
            {
                this.commands.Remove(name);
            }
            catch (KeyNotFoundException)
            {
            }

            for (int i = this.LinkedCommands.Count - 1; i >= 0; i--)
            {
                CommandLink link = this.LinkedCommands[i];
                if (link.SourceCommand == name)
                {
                    this.LinkedCommands.RemoveAt(i);
                }
            }
        }
コード例 #7
0
ファイル: Entity.cs プロジェクト: schmittens/Lemma
 public void Add(string name, Command cmd, Command.Perms perms = Command.Perms.Linkable, string description = null)
 {
     Command.Entry entry = new Command.Entry {
         Command = cmd, Permissions = perms, Key = name
     };
     if (this.main.EditorEnabled)
     {
         entry.Description = description;
     }
     this.commands.Add(name, entry);
     for (int i = 0; i < this.LinkedCommands.Count; i++)
     {
         CommandLink link = this.LinkedCommands[i];
         if (link.LinkedSourceCmd == null && name == link.SourceCommand)
         {
             link.LinkedSourceCmd = cmd;
             this.Add(new CommandBinding(link.LinkedSourceCmd, () => LinkedCommandCall(link)));
         }
     }
 }
コード例 #8
0
ファイル: TextFormatter.cs プロジェクト: deathlef/Vha.AOML
        public override string OnLinkOpen(LinkElement element)
        {
            switch (element.Link.Type)
            {
            case LinkType.Command:
                CommandLink command = (CommandLink)element.Link;
                return(this.prefix.Peek() + "command=" + command.Command + "\n");

            case LinkType.Window:
                WindowLink el = (WindowLink)element.Link;
                Formatter  f  = new TextFormatter(this.prefix.Peek() + "| ");
                return(f.Format(el.Element));

            case LinkType.Item:
                ItemLink item = (ItemLink)element.Link;
                return(this.prefix.Peek() +
                       "lid=" + item.LowID.ToString() +
                       " hid=" + item.HighID.ToString() +
                       " ql=" + item.Quality.ToString() + "\n");

            case LinkType.User:
                UserLink user = (UserLink)element.Link;
                return(this.prefix.Peek() + "character=" + user.Character + "\n");

            case LinkType.Other:
                OtherLink other = (OtherLink)element.Link;
                return(this.prefix.Peek() + "uri=" + other.Uri.ToString() + "\n");

            case LinkType.Invalid:
                InvalidLink invalid = (InvalidLink)element.Link;
                return(this.prefix.Peek() + "uri=" + invalid.Raw + "\n");

            default:
                return(this.prefix.Peek() +
                       "unknown LinkType: " +
                       element.Link.Type.ToString() + "\n");
            }
        }
コード例 #9
0
        public override string OnLinkOpen(LinkElement element)
        {
            string href  = "";
            string style = "";

            switch (element.Link.Type)
            {
            case LinkType.Command:
                CommandLink command = (CommandLink)element.Link;
                href = "chatcmd://" + Web.EscapeHtml(command.Command);
                break;

            case LinkType.Window:
                WindowLink window = (WindowLink)element.Link;
                Formatter  f      = null;
                if (this.Style == AomlFormatterStyle.DoubleQuote)
                {
                    f = new AomlFormatter(AomlFormatterStyle.SingleQuote);
                }
                else
                {
                    f = new PlainTextFormatter();
                }
                href = "text://" + f.Format(window.Element);
                break;

            case LinkType.Item:
                ItemLink item = (ItemLink)element.Link;
                href = string.Format("itemref://{0}/{1}/{2}",
                                     item.LowID,
                                     item.HighID,
                                     item.Quality);
                break;

            case LinkType.Entity:
                EntityLink entity = (EntityLink)element.Link;
                href = string.Format("itemid://{0}/{1}",
                                     entity.TypeID,
                                     entity.InstanceID);
                break;

            case LinkType.User:
                UserLink user = (UserLink)element.Link;
                href = "user://" + Web.EscapeHtml(user.Character);
                break;

            case LinkType.Other:
                OtherLink other = (OtherLink)element.Link;
                href = other.Uri.ToString();
                break;

            case LinkType.Invalid:
                href = "";     // Leave empty as it's potentially harmful
                break;
            }
            if (!element.Stylized)
            {
                style = string.Format(" style={0}text-decoration:none{0}", this.Quote);
            }
            return(string.Format("<a href={0}{1}{0}{2}>",
                                 this.Quote,
                                 href,
                                 style));
        }
コード例 #10
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.documentStrip = new PaintDotNet.DocumentStrip();
     this.documentListHeader = new PaintDotNet.HeaderLabel();
     this.hScrollBar = new System.Windows.Forms.HScrollBar();
     this.saveButton = new PaintDotNet.CommandLink();
     this.dontSaveButton = new PaintDotNet.CommandLink();
     this.cancelButton = new PaintDotNet.CommandLink();
     this.infoLabel = new System.Windows.Forms.Label();
     this.SuspendLayout();
     //
     // documentStrip
     //
     this.documentStrip.BackColor = System.Drawing.SystemColors.ButtonHighlight;
     this.documentStrip.DocumentClicked += new EventHandler<Pair<DocumentWorkspace, DocumentClickAction>>(DocumentList_DocumentClicked);
     this.documentStrip.EnsureSelectedIsVisible = false;
     this.documentStrip.ManagedFocus = true;
     this.documentStrip.Name = "documentList";
     this.documentStrip.ScrollOffset = 0;
     this.documentStrip.ScrollOffsetChanged += new EventHandler(DocumentList_ScrollOffsetChanged);
     this.documentStrip.ShowCloseButtons = false;
     this.documentStrip.ShowScrollButtons = false;
     this.documentStrip.TabIndex = 0;
     this.documentStrip.ThumbnailUpdateLatency = 10;
     //
     // documentListHeader
     //
     this.documentListHeader.Name = "documentListHeader";
     this.documentListHeader.RightMargin = 0;
     this.documentListHeader.TabIndex = 1;
     this.documentListHeader.TabStop = false;
     //
     // hScrollBar
     //
     this.hScrollBar.Name = "hScrollBar";
     this.hScrollBar.TabIndex = 2;
     this.hScrollBar.ValueChanged += new System.EventHandler(this.HScrollBar_ValueChanged);
     //
     // saveButton
     //
     this.saveButton.ActionImage = null;
     this.saveButton.AutoSize = true;
     this.saveButton.Name = "saveButton";
     this.saveButton.TabIndex = 4;
     this.saveButton.Click += new System.EventHandler(this.SaveButton_Click);
     //
     // dontSaveButton
     //
     this.dontSaveButton.ActionImage = null;
     this.dontSaveButton.AutoSize = true;
     this.dontSaveButton.Name = "dontSaveButton";
     this.dontSaveButton.TabIndex = 5;
     this.dontSaveButton.Click += new System.EventHandler(this.DontSaveButton_Click);
     //
     // cancelButton
     //
     this.cancelButton.ActionImage = null;
     this.cancelButton.AutoSize = true;
     this.cancelButton.Name = "cancelButton";
     this.cancelButton.TabIndex = 6;
     this.cancelButton.Click += new System.EventHandler(this.CancelButton_Click);
     //
     // infoLabel
     //
     this.infoLabel.Name = "infoLabel";
     this.infoLabel.TabIndex = 7;
     //
     // UnsavedChangesDialog
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
     this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
     this.ClientSize = new System.Drawing.Size(490, 100);
     this.Controls.Add(this.infoLabel);
     this.Controls.Add(this.documentListHeader);
     this.Controls.Add(this.cancelButton);
     this.Controls.Add(this.hScrollBar);
     this.Controls.Add(this.dontSaveButton);
     this.Controls.Add(this.documentStrip);
     this.Controls.Add(this.saveButton);
     this.AcceptButton = this.saveButton;
     this.CancelButton = this.cancelButton;
     this.FormBorderStyle = FormBorderStyle.FixedDialog;
     this.Location = new System.Drawing.Point(0, 0);
     this.MaximizeBox = false;
     this.MinimizeBox = false;
     this.Name = "UnsavedChangesDialog";
     this.ShowInTaskbar = false;
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
     this.Controls.SetChildIndex(this.saveButton, 0);
     this.Controls.SetChildIndex(this.documentStrip, 0);
     this.Controls.SetChildIndex(this.dontSaveButton, 0);
     this.Controls.SetChildIndex(this.hScrollBar, 0);
     this.Controls.SetChildIndex(this.cancelButton, 0);
     this.Controls.SetChildIndex(this.documentListHeader, 0);
     this.Controls.SetChildIndex(this.infoLabel, 0);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
コード例 #11
0
 private void RecreateButtons()
 {
     DeleteButtons();
     _IsOnlyOK = null;
     bool areButtons = Buttons != null && Buttons.Count > 0;
     PanelCommandLinks.Visibility = PanelRightButtons.Visibility = Visibility.Collapsed;
     if (areButtons)
     {
         (UseCommandLinks ? (Panel)PanelCommandLinks : (Panel)PanelRightButtons).Visibility = Visibility.Visible;
         foreach (TaskDialogButton b in Buttons)
         {
             CommandLink cl = null;
             Button btn = UseCommandLinks ? (Button)(cl = new CommandLink()) : new Button();
             if (string.IsNullOrEmpty(b.Text))
             {
                 btn.Content = b.Result.ToLocalizedString();
             }
             else if (UseCommandLinks)
             {
                 cl.Content = b.Text;
                 cl.Note = string.IsNullOrEmpty(b.Note) ? (object)b.Note : new TextBlock(new Run(b.Note)) { TextWrapping = TextWrapping.Wrap, MaxWidth = 800 };
                 cl.Icon = b.IsElevationRequired ? CommandLinkIcon.Shield : (UseCommandLinksNoIcon ? CommandLinkIcon.None : CommandLinkIcon.Arrow);
             }
             else
             {
                 btn.Content = b.Text;
             }
             btn.Click += Button_Click;
             btn.Tag = b;
             if (b.Result == TaskDialogResult.Cancel)
             {
                 btn.IsCancel = true;
             }
             if (b.Result == TaskDialogResult.OK && _IsOnlyOK == null)
             {
                 _IsOnlyOK = true;
             }
             else
             {
                 _IsOnlyOK = false;
             }
             (UseCommandLinks ? (Panel)PanelCommandLinks : (Panel)PanelRightButtons).Children.Add(btn);
         }
     }
     TaskDialogCommonButtons commonButtons = CommonButtons;
     if ((Buttons == null || Buttons.Count == 0) && commonButtons == TaskDialogCommonButtons.None)
     {
         commonButtons = TaskDialogCommonButtons.OK;
     }
     areButtons = commonButtons != TaskDialogCommonButtons.None;
     if (areButtons)
     {
         foreach (TaskDialogCommonButtons cb in TaskDialogHelpers.CommonButtonsOrder)
         {
             if ((commonButtons & cb) != TaskDialogCommonButtons.None)
             {
                 PanelRightButtons.Visibility = Visibility.Visible;
                 Button btn = new Button();
                 btn.Content = cb.ToLocalizedString();
                 btn.Click += Button_Click;
                 btn.Tag = cb;
                 if (cb == TaskDialogCommonButtons.Cancel)
                 {
                     btn.IsCancel = true;
                 }
                 if (cb == TaskDialogCommonButtons.OK && _IsOnlyOK == null)
                 {
                     _IsOnlyOK = true;
                 }
                 else
                 {
                     _IsOnlyOK = false;
                 }
                 PanelRightButtons.Children.Add(btn);
             }
         }
     }
     foreach (Button b in PanelRightButtons.Children)
     {
         if (!_IsTaskDialog)
         {
             b.MinWidth = TaskDialogHelpers.IsSegoeUIInstalled ? 88.0 : 75.0;
         }
         else
         {
             //double d = b.ActualWidth;
             //if (d < 68.0) d = 68.0;
             b.MinWidth = /*Math.Ceiling((d - 68.0) / 20.0) * 20.0 +*/ 68.0;
         }
         if (!_IsTaskDialog)
         {
             b.MinHeight = TaskDialogHelpers.IsSegoeUIInstalled ? 26.0 : 23.0;
         }
         else
         {
             b.MinHeight = 23.0;
         }
     }
     SetDefaultButton();
     RecheckCancellation();
 }
コード例 #12
0
        public override string OnLinkOpen(LinkElement element)
        {
            // Transform link
            string href  = "";
            string title = "";

            switch (element.Link.Type)
            {
            case LinkType.Command:
                CommandLink command = (CommandLink)element.Link;
                href  = "chatcmd://" + HttpUtility.UrlEncode(command.Command);
                title = Web.EscapeHtml(command.Command);
                break;

            case LinkType.Window:
                WindowLink window = (WindowLink)element.Link;
                href = "text://" + this._cache.CacheElement(window.Element).ToString();
                break;

            case LinkType.Item:
                ItemLink item = (ItemLink)element.Link;
                href = string.Format("itemref://{0}/{1}/{2}",
                                     item.LowID, item.HighID, item.Quality);
                title = href;
                break;

            case LinkType.Entity:
                EntityLink entity = (EntityLink)element.Link;
                href = string.Format("itemid://{0}/{1}",
                                     entity.TypeID, entity.InstanceID);
                title = href;
                break;

            case LinkType.User:
                UserLink user = (UserLink)element.Link;
                href  = "character://" + HttpUtility.UrlEncode(user.Character);
                title = Web.EscapeHtml(user.Character);
                break;

            case LinkType.Other:
                OtherLink other = (OtherLink)element.Link;
                href  = other.Uri.ToString();
                title = Web.EscapeHtml(href);
                break;

            case LinkType.Invalid:
                InvalidLink invalid = (InvalidLink)element.Link;
                href  = "";    // Leave link empty as it's potentially harmfull
                title = Web.EscapeHtml(invalid.Raw);
                break;
            }
            // Handle 'no-style' links
            string style = "";

            if (!element.Stylized)
            {
                // Find parent color
                Color   color  = null;
                Element parent = element;
                if (this._style != TextStyle.Strip)
                {
                    while ((parent = parent.Parent) != null)
                    {
                        if (parent.Type != ElementType.Color)
                        {
                            continue;
                        }
                        color = ((ColorElement)parent).Color;
                        break;
                    }
                }
                // Transform color into a html style
                if (color != null)
                {
                    if (this._style == TextStyle.Invert)
                    {
                        color = _invert(color);
                    }
                    style = string.Format(
                        " class=\"NoStyle\" style=\"color: #{0:X2}{1:X2}{2:X2}\"",
                        color.Red, color.Green, color.Blue);
                }
                else
                {
                    style = " class=\"NoStyle\"";
                }
            }
            return(string.Format("<a href=\"{0}\" title=\"{1}\"{2}>", href, Web.EscapeHtml(title), style));
        }
コード例 #13
0
ファイル: Dominizer.cs プロジェクト: deathlef/Vha.AOML
        protected Element CreateLinkElement(OpenNode node)
        {
            // Valid link?
            string href = node.GetAttribute("href");

            if (string.IsNullOrEmpty(href) || !href.Contains("://"))
            {
                return(new ContainerElement());
            }
            // Parse link
            int index = href.IndexOf("://");

            if (index <= 0)
            {
                return(new ContainerElement());
            }
            string  type          = href.Substring(0, index).ToLower();
            string  argument      = href.Substring(index + 3);
            Link    link          = null;
            Element windowElement = null;
            // Verify header
            Regex validCharacters = new Regex("^[a-zA-Z]+$");

            if (!validCharacters.IsMatch(type) || argument.Length == 0)
            {
                // Invalid link
                link = new InvalidLink(href);
            }
            else
            {
                // Generate link
                switch (type)
                {
                case "text":
                    windowElement = Parse(argument);
                    if (windowElement == null)
                    {
                        break;
                    }
                    link = new WindowLink(windowElement);
                    break;

                case "charref":
                    index = argument.IndexOf("/");
                    if (index < 0)
                    {
                        break;
                    }
                    index = argument.IndexOf("/", index + 1);
                    if (index <= 0)
                    {
                        break;
                    }
                    argument      = argument.Substring(index + 1);
                    windowElement = Parse(argument);
                    if (windowElement == null)
                    {
                        break;
                    }
                    link = new WindowLink(windowElement);
                    break;

                case "itemref":
                    string[] itemParts = argument.Split('/');
                    if (itemParts.Length != 3)
                    {
                        break;
                    }
                    uint lowId, highId, ql;
                    if (!uint.TryParse(itemParts[0], out lowId))
                    {
                        break;
                    }
                    if (!uint.TryParse(itemParts[1], out highId))
                    {
                        break;
                    }
                    if (!uint.TryParse(itemParts[2], out ql))
                    {
                        break;
                    }
                    link = new ItemLink(lowId, highId, ql);
                    break;

                case "itemid":
                    string[] entityParts = argument.Split('/');
                    // itemid:// can come with 4 arguments, but we have no use for the last 2
                    if (entityParts.Length != 2 && entityParts.Length != 4)
                    {
                        break;
                    }
                    uint typeId, instanceId;
                    if (!uint.TryParse(entityParts[0], out typeId))
                    {
                        break;
                    }
                    if (!uint.TryParse(entityParts[1], out instanceId))
                    {
                        break;
                    }
                    link = new EntityLink(typeId, instanceId);
                    break;

                case "chatcmd":
                    link = new CommandLink(argument);
                    break;

                case "user":
                    link = new UserLink(argument);
                    break;

                default:
                    try
                    {
                        // Attempt to create an 'OtherLink'
                        // this operation will throw an exception if the 'href' is significantly malformed
                        link = new OtherLink(href);
                    }
                    catch (UriFormatException)
                    {
                        // The 'href' is malformed, store as InvalidLink
                        link = new InvalidLink(href);
                    }
                    break;
                }
            }
            if (link == null)
            {
                return(new ContainerElement());
            }
            string style = node.GetAttribute("style");

            if (style != null)
            {
                style = style.Replace(" ", "").ToLower();
                if (!style.Contains("text-decoration:none"))
                {
                    style = null;
                }
            }
            return(new LinkElement(link, style == null));
        }
コード例 #14
0
ファイル: TaskDialog.cs プロジェクト: leejungho2/xynotecgui
            private void InitCommandLinks()
            {
                SuspendLayout();

                if (this.commandLinks != null)
                {
                    foreach (CommandLink commandLink in this.commandLinks)
                    {
                        Controls.Remove(commandLink);
                        commandLink.Tag = null;
                        commandLink.Click -= CommandLink_Click;
                        commandLink.Dispose();
                    }

                    this.commandLinks = null;
                }

                this.commandLinks = new CommandLink[this.taskButtons.Length];

                IButtonControl newAcceptButton = null;
                IButtonControl newCancelButton = null;

                for (int i = 0; i < this.commandLinks.Length; ++i)
                {
                    TaskButton taskButton = this.taskButtons[i];
                    CommandLink commandLink = new CommandLink();

                    commandLink.ActionText = taskButton.ActionText;
                    commandLink.ActionImage = taskButton.Image;
                    commandLink.AutoSize = true;
                    commandLink.ExplanationText = taskButton.ExplanationText;
                    commandLink.Tag = taskButton;
                    commandLink.Click += CommandLink_Click;

                    this.commandLinks[i] = commandLink;
                    Controls.Add(commandLink);

                    if (this.acceptTaskButton == taskButton)
                    {
                        newAcceptButton = commandLink;
                    }

                    if (this.cancelTaskButton == taskButton)
                    {
                        newCancelButton = commandLink;
                    }
                }

                AcceptButton = newAcceptButton;
                CancelButton = newCancelButton;

                ResumeLayout();
            }
コード例 #15
0
        private void RecreateButtons()
        {
            DeleteButtons();
            _IsOnlyOK = null;
            bool areButtons = Buttons != null && Buttons.Count > 0;

            PanelCommandLinks.Visibility = PanelRightButtons.Visibility = Visibility.Collapsed;
            if (areButtons)
            {
                (UseCommandLinks ? (Panel)PanelCommandLinks : (Panel)PanelRightButtons).Visibility = Visibility.Visible;
                foreach (TaskDialogButton b in Buttons)
                {
                    CommandLink cl  = null;
                    Button      btn = UseCommandLinks ? (Button)(cl = new CommandLink()) : new Button();
                    if (string.IsNullOrEmpty(b.Text))
                    {
                        btn.Content = b.Result.ToLocalizedString();
                    }
                    else if (UseCommandLinks)
                    {
                        cl.Content = b.Text;
                        cl.Note    = string.IsNullOrEmpty(b.Note) ? (object)b.Note : new TextBlock(new Run(b.Note))
                        {
                            TextWrapping = TextWrapping.Wrap, MaxWidth = 800
                        };
                        cl.Icon = b.IsElevationRequired ? CommandLinkIcon.Shield : (UseCommandLinksNoIcon ? CommandLinkIcon.None : CommandLinkIcon.Arrow);
                    }
                    else
                    {
                        btn.Content = b.Text;
                    }
                    btn.Click += Button_Click;
                    btn.Tag    = b;
                    if (b.Result == TaskDialogResult.Cancel)
                    {
                        btn.IsCancel = true;
                    }
                    if (b.Result == TaskDialogResult.OK && _IsOnlyOK == null)
                    {
                        _IsOnlyOK = true;
                    }
                    else
                    {
                        _IsOnlyOK = false;
                    }
                    (UseCommandLinks ? (Panel)PanelCommandLinks : (Panel)PanelRightButtons).Children.Add(btn);
                }
            }
            TaskDialogCommonButtons commonButtons = CommonButtons;

            if ((Buttons == null || Buttons.Count == 0) && commonButtons == TaskDialogCommonButtons.None)
            {
                commonButtons = TaskDialogCommonButtons.OK;
            }
            areButtons = commonButtons != TaskDialogCommonButtons.None;
            if (areButtons)
            {
                foreach (TaskDialogCommonButtons cb in TaskDialogHelpers.CommonButtonsOrder)
                {
                    if ((commonButtons & cb) != TaskDialogCommonButtons.None)
                    {
                        PanelRightButtons.Visibility = Visibility.Visible;
                        Button btn = new Button();
                        btn.Content = cb.ToLocalizedString();
                        btn.Click  += Button_Click;
                        btn.Tag     = cb;
                        if (cb == TaskDialogCommonButtons.Cancel)
                        {
                            btn.IsCancel = true;
                        }
                        if (cb == TaskDialogCommonButtons.OK && _IsOnlyOK == null)
                        {
                            _IsOnlyOK = true;
                        }
                        else
                        {
                            _IsOnlyOK = false;
                        }
                        PanelRightButtons.Children.Add(btn);
                    }
                }
            }
            foreach (Button b in PanelRightButtons.Children)
            {
                if (!_IsTaskDialog)
                {
                    b.MinWidth = TaskDialogHelpers.IsSegoeUIInstalled ? 88.0 : 75.0;
                }
                else
                {
                    //double d = b.ActualWidth;
                    //if (d < 68.0) d = 68.0;
                    b.MinWidth = /*Math.Ceiling((d - 68.0) / 20.0) * 20.0 +*/ 68.0;
                }
                if (!_IsTaskDialog)
                {
                    b.MinHeight = TaskDialogHelpers.IsSegoeUIInstalled ? 26.0 : 23.0;
                }
                else
                {
                    b.MinHeight = 23.0;
                }
            }
            SetDefaultButton();
            RecheckCancellation();
        }
コード例 #16
0
        public void Add(string url)
        {
            #region GENERATED CODE
            VistaControls.ProgressBar pbPercent = new VistaControls.ProgressBar();
            VistaControls.ThemeText.ThemedLabel lblName = new VistaControls.ThemeText.ThemedLabel();
            VistaControls.ThemeText.ThemedLabel lblPercent = new VistaControls.ThemeText.ThemedLabel();
            VistaControls.ThemeText.ThemedLabel lblSizeInfo = new VistaControls.ThemeText.ThemedLabel();
            VistaControls.Button btnCancel = new VistaControls.Button();

            System.Windows.Forms.Panel panel = new System.Windows.Forms.Panel();
            panel.SuspendLayout();
            //
            // pbPercent
            //
            pbPercent.Location = new System.Drawing.Point(3, 40);
            pbPercent.Name = "pbPercent";
            pbPercent.Size = new System.Drawing.Size(373, 23);
            pbPercent.TabIndex = 6;
            //
            // lblName
            //
            lblName.BorderSize = 10;
            lblName.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lblName.Location = new System.Drawing.Point(3, 4);
            lblName.Name = "lblName";
            lblName.Padding = new System.Windows.Forms.Padding(10, 9, 0, 0);
            lblName.Size = new System.Drawing.Size(334, 34);
            lblName.TabIndex = 9;
            lblName.Text = "Loading";
            //
            // btnCancel
            //
            btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
            btnCancel.Image = Download_Manager.Properties.Resources.icon_cross.ToBitmap();
            btnCancel.Location = new System.Drawing.Point(376-22, 10);
            btnCancel.Name = "btnCancel";
            btnCancel.Size = new System.Drawing.Size(22, 23);
            btnCancel.TabIndex = 11;
            btnCancel.Text = " ";
            btnCancel.TextAlign = System.Drawing.ContentAlignment.BottomRight;
            btnCancel.UseVisualStyleBackColor = true;
            btnCancel.Parent = panel;
            btnCancel.Show();
            //
            // lblPercent
            //
            lblPercent.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lblPercent.Location = new System.Drawing.Point(3, 63);
            lblPercent.Name = "lblPercent";
            lblPercent.Size = new System.Drawing.Size(196, 27);
            lblPercent.TabIndex = 7;
            lblPercent.Text = ".............";
            lblPercent.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            //
            // lblSizeInfo
            //
            lblSizeInfo.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lblSizeInfo.Location = new System.Drawing.Point(205, 63);
            lblSizeInfo.Name = "lblSizeInfo";
            lblSizeInfo.Size = new System.Drawing.Size(172, 27);
            lblSizeInfo.TabIndex = 8;
            lblSizeInfo.Text = ".............";
            lblSizeInfo.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            //
            // panel
            //
            panel.BackColor = System.Drawing.Color.Transparent;
            panel.Controls.Add(pbPercent);
            panel.Controls.Add(lblSizeInfo);
            panel.Controls.Add(lblName);
            //panel.Controls.Add(btnCancel);
            panel.Controls.Add(lblPercent);
            panel.ForeColor = System.Drawing.Color.Black;
            panel.Location = new System.Drawing.Point(12, 12);
            panel.Name = "panel";
            panel.Size = new System.Drawing.Size(376, 99);
            panel.TabIndex = 10;
            #endregion

            panel.Parent = this._Form;

            //btnCancel.Parent = _Form;
            Download dl = new Download(url, "", panel, pbPercent, lblName, lblSizeInfo, lblPercent, btnCancel);
            dl.SaveTo = Environment.GetEnvironmentVariable("USERPROFILE") + Path.DirectorySeparatorChar + "Downloads" + Path.DirectorySeparatorChar + dl.Name;
            btnCancel.Click += delegate(object sender, EventArgs e)
            {
                dl.Stop();
                dl.RemoveControls();
                panels.Remove(panel);
                panel.Dispose();
                RePosition();
            };

            DateTime start = DateTime.Now;
            dl.Start(start, delegate()
            {
                dl.RemoveControls();
                CommandLink btn = new CommandLink();
                btn.Parent = dl._Panel;
                btn.SetBounds(1, 1, dl._Panel.Width - 1, dl._Panel.Height - 10);
                btn.Text = "Open";
                btn.Note = "Open " + dl.Name;
                btn.Click += delegate(object sender, EventArgs args)
                {
                    try
                    {
                        ProcessStartInfo info = new ProcessStartInfo(dl.SaveTo);
                        Process.Start(info);
                    }
                    catch { }
                    dl.RemoveControls();
                    panels.Remove(dl._Panel);
                    dl._Panel.Dispose();
                    RePosition();
                };

            });

            downloads.AddLast(dl);
            panels.AddLast(panel);
            RePosition();
        }
コード例 #17
0
ファイル: CommandDialog.cs プロジェクト: divyang4481/lextudio
 private void CommandLinkSelected(object sender, System.EventArgs e)
 {
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
     if (sender != null && sender is CommandLink)
     {
         mSelectedCommandLink = (CommandLink)sender;
     }
     this.Close();
 }