/// <summary> /// set image control properties /// </summary> /// <param name="control"></param> internal override void setSpecificControlProperties(Control control) { GuiUtils.setImageInfoOnTagData(control, OrgImage, ImageStyle); GuiUtils.setBackgroundImage(control); }
void linkManually_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { GuiUtils.OpenBrowser("https://www.canyouseeme.org/"); }
private void EditMI_Click(object sender, EventArgs e) { try { if (ItemsLV.SelectedItems.Count != 1) { return; } ValueState state = ItemsLV.SelectedItems[0].Tag as ValueState; if (!IsEditableType(state.Component)) { return; } object value = new SimpleValueEditDlg().ShowDialog(state.Component, state.Component.GetType()); if (value == null) { return; } if (state.Value is IEncodeable) { PropertyInfo property = (PropertyInfo)state.ComponentId; MethodInfo[] accessors = property.GetAccessors(); for (int ii = 0; ii < accessors.Length; ii++) { if (accessors[ii].ReturnType == typeof(void)) { accessors[ii].Invoke(state.Value, new object[] { value }); state.Component = value; break; } } } DataValue datavalue = state.Value as DataValue; if (datavalue != null) { int component = (int)state.ComponentId; switch (component) { case 0: { datavalue.Value = value; break; } } } if (state.Value is IList) { int ii = (int)state.ComponentId; ((IList)state.Value)[ii] = value; state.Component = value; } m_expanding = false; int index = 0; bool overwrite = true; ShowValue(ref index, ref overwrite, state.Value); } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
void Chat_MembersUpdate() { MemberTree.BeginUpdate(); MemberTree.Nodes.Clear(); NodeMap.Clear(); List <ulong> users = new List <ulong>(); Room.Members.LockReading(delegate() { if (Room.Members.SafeCount == 0) { MemberTree.EndUpdate(); return; } users = Room.Members.ToList(); TreeListNode root = MemberTree.virtualParent; if (Room.Host != 0) { root = new MemberNode(this, Room.Host); if (Room.IsLoop) { ((MemberNode)root).IsLoopRoot = true; } else { NodeMap[Room.Host] = root as MemberNode; } UpdateNode(root as MemberNode); MemberTree.Nodes.Add(root); root.Expand(); } foreach (ulong id in Room.Members) { if (id != Room.Host) { // if they left the room dont show them if (!ChatService.IsCommandRoom(Room.Kind)) { if (Room.Members.SafeCount == 0) { continue; } } MemberNode node = new MemberNode(this, id); NodeMap[id] = node; UpdateNode(node); GuiUtils.InsertSubNode(root, node); } } }); MemberTree.EndUpdate(); if (VoiceButton != null) { AudioDirection direction = AudioDirection.Both; if (ParentView.ViewHigh != null && ParentView.ViewLow != null) { if (Room.Kind == RoomKind.Command_High || Room.Kind == RoomKind.Live_High) { direction = AudioDirection.Left; } else if (Room.Kind == RoomKind.Command_Low || Room.Kind == RoomKind.Live_Low) { direction = AudioDirection.Right; } } VoiceButton.SetUsers(users, direction); } }
private void lblTitle_Click_1(object sender, EventArgs e) { GuiUtils.OpenUrl(Provider.DefinitionHref); }
public virtual void OnListViewDrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawDefault = false; Form.Skin.GraphicsCommon(e.Graphics); DrawSubItemBackground(e); if (GetDrawSubItemFull(e.ColumnIndex) == false) { return; } if (e.ColumnIndex == 0) { Rectangle r = e.Bounds; r.Height--; Image imageState = GuiUtils.GetResourceImage(ImageStateResourcePrefix + e.Item.StateImageIndex.ToString()); if (imageState != null) { int imageWidth = r.Height; Rectangle rImage = r; rImage.X += ImageSpace; rImage.Width = imageWidth; Form.DrawImageContain(e.Graphics, imageState, rImage, 20); //e.Graphics.DrawImage(imageState, rImage); r.X += (imageWidth + ImageSpace); r.Width -= (imageWidth + ImageSpace); } Image imageIcon = GuiUtils.GetResourceImage(ImageIconResourcePrefix + e.Item.ImageKey); if ((imageIcon == null) && (ImageListIcon != null) && (ImageListIcon.Images.ContainsKey(e.Item.ImageKey))) { imageIcon = ImageListIcon.Images[e.Item.ImageKey]; } else if ((imageIcon == null) && (e.Item.ListView.LargeImageList != null) && (e.Item.ListView.LargeImageList.Images.ContainsKey(e.Item.ImageKey))) { imageIcon = e.Item.ListView.LargeImageList.Images[e.Item.ImageKey]; } else if ((imageIcon == null) && (e.Item.ListView.SmallImageList != null) && (e.Item.ListView.SmallImageList.Images.ContainsKey(e.Item.ImageKey))) { imageIcon = e.Item.ListView.SmallImageList.Images[e.Item.ImageKey]; } if (imageIcon != null) { //int imageWidth = r.Height; int imageHeight = r.Height; int imageWidth = (imageHeight * imageIcon.Width) / imageIcon.Height; Rectangle rImage = r; rImage.X += ImageSpace; rImage.Width = imageWidth; //e.Graphics.DrawImage(imageIcon, rImage); Form.DrawImageContain(e.Graphics, imageIcon, rImage, 20); r.X += (imageWidth + ImageSpace); r.Width -= (imageWidth + ImageSpace); } r.X += TextSpace; r.Width -= TextSpace; Form.DrawString(e.Graphics, e.Item.Text, e.Item.Font, Form.Skin.ForeBrush, r, GuiUtils.StringFormatLeftMiddle); } else { Rectangle r = e.Bounds; r.Height--; r.X += TextSpace; r.Width -= TextSpace; StringFormat stringFormat = GuiUtils.StringFormatLeftMiddle; if (e.Item.ListView.Columns[e.ColumnIndex].TextAlign == HorizontalAlignment.Center) { stringFormat = GuiUtils.StringFormatCenterMiddle; } else if (e.Item.ListView.Columns[e.ColumnIndex].TextAlign == HorizontalAlignment.Right) { stringFormat = GuiUtils.StringFormatRightMiddle; } Form.DrawString(e.Graphics, e.Item.SubItems[e.ColumnIndex].Text, e.Item.Font, Form.Skin.ForeBrush, r, stringFormat); } }
/// <summary> /// Connects to a server. /// </summary> /// <param name="endpoint">The server endpoint</param> /// <param name="oldlvi">null if a new connection. non-null if an existing disconnected connection</param> public void Connect(ConfiguredEndpoint endpoint, ListViewItem oldlvi) { try { if (endpoint == null) { return; } if (ServerListView.Items.ContainsKey(endpoint.ToString())) { MessageBox.Show("endpoint already in use"); return; } ServerConnection connection = new ServerConnection(endpoint); if (connection.m_Endpoint.UpdateBeforeConnect) { UpdateEndpoint(connection.m_Endpoint); } // create the channel. connection.m_channel = SessionChannel.Create( m_configuration, connection.m_Endpoint.Description, connection.m_Endpoint.Configuration, m_bindingFactory, m_configuration.SecurityConfiguration.ApplicationCertificate.Find(), null); connection.m_session = new Session(connection.m_channel, m_configuration, connection.m_Endpoint); connection.m_session.ReturnDiagnostics = DiagnosticsMasks.All; // Set up good defaults connection.m_session.DefaultSubscription.PublishingInterval = 1000; connection.m_session.DefaultSubscription.KeepAliveCount = 3; connection.m_session.DefaultSubscription.Priority = 0; connection.m_session.DefaultSubscription.PublishingEnabled = true; connection.m_session.DefaultSubscription.DefaultItem.SamplingInterval = 1000; if (new SessionOpenDlg().ShowDialog(connection.m_session, new List <string>()) == true) { NodeId ServerStartTimeNodeId = new NodeId(Variables.Server_ServerStatus_StartTime); NodeId ServerCurrentTimeNodeId = new NodeId(Variables.Server_ServerStatus_CurrentTime); NodeId ServerStateNodeId = new NodeId(Variables.Server_ServerStatus_State); // Save in the map m_Connections.Add(connection.m_Endpoint.Description.EndpointUrl.ToString(), connection); // Add to list control ListViewItem lvi = ServerListView.Items.Add(connection.m_session.SessionId.ToString(), "", -1); lvi.SubItems.Add("").Name = ServerStartTimeNodeId.Identifier.ToString(); lvi.SubItems.Add("").Name = ServerCurrentTimeNodeId.Identifier.ToString(); lvi.SubItems.Add("").Name = ServerStateNodeId.Identifier.ToString(); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.Tag = connection; if (oldlvi != null) { ServerListView.Items.Remove(oldlvi); } connection.m_session.KeepAlive += new KeepAliveEventHandler(StandardClient_KeepAlive); connection.m_Subscription = new Subscription(connection.m_session.DefaultSubscription); connection.m_Subscription.DisplayName = connection.m_session.ToString(); bool bResult = connection.m_session.AddSubscription(connection.m_Subscription); connection.m_Subscription.Create(); MonitoredItem startTimeItem = new MonitoredItem(connection.m_Subscription.DefaultItem); INode node = connection.m_session.NodeCache.Find(ServerStartTimeNodeId); startTimeItem.DisplayName = connection.m_session.NodeCache.GetDisplayText(node); startTimeItem.StartNodeId = ServerStartTimeNodeId; startTimeItem.NodeClass = (NodeClass)node.NodeClass; startTimeItem.AttributeId = Attributes.Value; connection.m_Subscription.AddItem(startTimeItem); startTimeItem.Notification += m_ItemNotification; MonitoredItem currentTimeItem = new MonitoredItem(connection.m_Subscription.DefaultItem); INode currentTimeNode = connection.m_session.NodeCache.Find(ServerCurrentTimeNodeId); currentTimeItem.DisplayName = connection.m_session.NodeCache.GetDisplayText(currentTimeNode); currentTimeItem.StartNodeId = ServerCurrentTimeNodeId; currentTimeItem.NodeClass = (NodeClass)currentTimeNode.NodeClass; currentTimeItem.AttributeId = Attributes.Value; connection.m_Subscription.AddItem(currentTimeItem); currentTimeItem.Notification += m_ItemNotification; MonitoredItem stateItem = new MonitoredItem(connection.m_Subscription.DefaultItem); INode stateNode = connection.m_session.NodeCache.Find(ServerStateNodeId); stateItem.DisplayName = connection.m_session.NodeCache.GetDisplayText(stateNode); stateItem.StartNodeId = ServerStateNodeId; stateItem.NodeClass = (NodeClass)stateNode.NodeClass; stateItem.AttributeId = Attributes.Value; connection.m_Subscription.AddItem(stateItem); connection.m_Subscription.ApplyChanges(); stateItem.Notification += m_ItemNotification; } } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
private void WriteMI_Click(object sender, EventArgs e) { try { // get the current session. Session session = Get <Session>(NodesTV.SelectedNode); if (session == null || !session.Connected) { return; } // build list of nodes to read. WriteValueCollection values = new WriteValueCollection(); MonitoredItem monitoredItem = Get <MonitoredItem>(NodesTV.SelectedNode); if (monitoredItem != null) { WriteValue value = new WriteValue(); value.NodeId = monitoredItem.ResolvedNodeId; value.AttributeId = monitoredItem.AttributeId; value.IndexRange = monitoredItem.IndexRange; MonitoredItemNotification datachange = monitoredItem.LastValue as MonitoredItemNotification; if (datachange != null) { value.Value = (DataValue)Utils.Clone(datachange.Value); } values.Add(value); } else { Subscription subscription = Get <Subscription>(NodesTV.SelectedNode); if (subscription != null) { foreach (MonitoredItem item in subscription.MonitoredItems) { WriteValue value = new WriteValue(); value.NodeId = item.ResolvedNodeId; value.AttributeId = item.AttributeId; value.IndexRange = item.IndexRange; MonitoredItemNotification datachange = item.LastValue as MonitoredItemNotification; if (datachange != null) { value.Value = (DataValue)Utils.Clone(datachange.Value); } values.Add(value); } } } // show form. new WriteDlg().Show(session, values); } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
private void SessionLoadMI_Click(object sender, EventArgs e) { try { // get selected session. Session session = SelectedTag as Session; if (session == null) { return; } // create a default file. if (String.IsNullOrEmpty(m_filePath)) { FileInfo defaultInfo = new FileInfo(Application.ExecutablePath); m_filePath = defaultInfo.DirectoryName; m_filePath += Path.DirectorySeparatorChar; m_filePath += session.SessionName; m_filePath += ".xml"; } FileInfo fileInfo = new FileInfo(m_filePath); OpenFileDialog dialog = new OpenFileDialog(); dialog.CheckFileExists = true; dialog.CheckPathExists = true; dialog.DefaultExt = ".xml"; dialog.Filter = "Result Files (*.xml)|*.xml|All Files (*.*)|*.*"; dialog.Multiselect = false; dialog.ValidateNames = true; dialog.Title = "Load Subscriptions"; dialog.FileName = m_filePath; dialog.InitialDirectory = fileInfo.DirectoryName; dialog.RestoreDirectory = true; if (dialog.ShowDialog() != DialogResult.OK) { return; } // remember file path. m_filePath = dialog.FileName; // load file. IEnumerable <Subscription> subscriptions = session.Load(dialog.FileName); // create the subscriptions automatically if the session is connected. if (session.Connected) { foreach (Subscription subscription in subscriptions) { subscription.Create(); } } } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
private void StatusBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e) { string url = e.Url.OriginalString; if (GuiUtils.IsRunningOnMono() && url.StartsWith("wyciwyg")) { return; } if (url.StartsWith("about:blank")) { return; } url = url.Replace("http://", ""); url = url.TrimEnd('/'); string[] command = url.Split('/'); if (CurrentMode == StatusModeType.Project) { if (url == "rename") { GetTextDialog rename = new GetTextDialog("Rename Project", "Enter new name for project " + Core.Trust.GetProjectName(ProjectID), Core.Trust.GetProjectName(ProjectID)); if (rename.ShowDialog() == DialogResult.OK) { Core.Trust.RenameProject(ProjectID, rename.ResultBox.Text); } } else if (url == "leave") { if (MessageBox.Show("Are you sure you want to leave " + Core.Trust.GetProjectName(ProjectID) + "?", "Leave Project", MessageBoxButtons.YesNo) == DialogResult.Yes) { Core.Trust.LeaveProject(ProjectID); } } else if (url == "settings") { new DeOps.Interface.Settings.Operation(Core).ShowDialog(this); } } else if (CurrentMode == StatusModeType.Group) { if (url == "add_buddy") { BuddyView.AddBuddyDialog(Core, ""); } else if (url == "add_group") { // not enabled yet } else if (command[0] == "rename_group") { string name = command[1]; GetTextDialog rename = new GetTextDialog("Rename Group", "Enter a new name for group " + name, name); if (rename.ShowDialog() == DialogResult.OK) { Core.Buddies.RenameGroup(name, rename.ResultBox.Text); } } else if (command[0] == "remove_group") { string name = command[1]; if (MessageBox.Show("Are you sure you want to remove " + name + "?", "Remove Group", MessageBoxButtons.YesNo) == DialogResult.Yes) { Core.Buddies.RemoveGroup(name); } } } else if (CurrentMode == StatusModeType.User) { if (url == "rename_user") { GetTextDialog rename = new GetTextDialog("Rename User", "New name for " + Core.GetName(UserID), Core.GetName(UserID)); if (rename.ShowDialog() == DialogResult.OK) { Core.RenameUser(UserID, rename.ResultBox.Text); } } else if (url == "trust_accept") { Core.Trust.AcceptTrust(UserID, ProjectID); } else if (command[0] == "change_title") { string def = command[1]; GetTextDialog title = new GetTextDialog("Change Title", "Enter title for " + Core.GetName(UserID), def); if (title.ShowDialog() == DialogResult.OK) { Core.Trust.SetTitle(UserID, ProjectID, title.ResultBox.Text); } } else if (url == "edit_location") { GetTextDialog place = new GetTextDialog("Change Location", "Where is this instance located? (home, work, mobile?)", ""); if (place.ShowDialog() == DialogResult.OK) { Core.User.Settings.Location = place.ResultBox.Text; Core.Locations.UpdateLocation(); Core.RunInCoreAsync(() => Core.User.Save()); } } else if (url == "edit_status") { // show edit status dialog available / away / invisible new StatusForm(Core).ShowDialog(); } else if (url == "unignore") { if (MessageBox.Show("Stop ignoring " + Core.GetName(UserID) + "?", "Ignore", MessageBoxButtons.YesNo) == DialogResult.Yes) { Core.Buddies.Ignore(UserID, false); } } else if (command[0] == "project") { uint id = uint.Parse(command[1]); if (UI.GuiMain != null && UI.GuiMain.GetType() == typeof(MainForm)) { ((MainForm)UI.GuiMain).ShowProject(id); } } else if (command[0] == "use_name") { string name = System.Web.HttpUtility.UrlDecode(command[1]); if (MessageBox.Show("Change " + Core.GetName(UserID) + "'s name to " + name + "?", "Change Name", MessageBoxButtons.YesNo) == DialogResult.Yes) { Core.RenameUser(UserID, name); } } else if (url == "im") { if (IM != null) { IM.OpenIMWindow(UserID); } } else if (url == "mail") { if (Mail != null) { Mail.OpenComposeWindow(UserID); } } else if (url == "buddy_who") { if (Buddy != null) { Buddy.ShowIdentity(UserID); } } else if (url == "trust") { Core.Trust.LinkupTo(UserID, ProjectID); } else if (url == "untrust") { Core.Trust.UnlinkFrom(UserID, ProjectID); } } else if (CurrentMode == StatusModeType.Network) { if (url == "settings") { new DeOps.Interface.Settings.Connection(Core).ShowDialog(this); } } e.Cancel = true; }
/* (non-Javadoc) * @see org.eclipse.swt.widgets.Handler#handleEvent(org.eclipse.swt.widgets.Event) */ internal override void handleEvent(EventType type, Object sender, EventArgs e) { ControlsMap controlsMap = ControlsMap.getInstance(); RichTextBox richTextCtrl = (RichTextBox)sender; MapData mapData = controlsMap.getMapData(richTextCtrl); if (mapData == null) { return; } GuiMgControl ctrl = mapData.getControl(); GuiMgForm guiMgForm = mapData.getForm(); UtilImeJpn utilImeJpn = Manager.UtilImeJpn; // JPN: IME support var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(ctrl)); try { switch (type) { case EventType.GOT_FOCUS: // check the paste enable. check the clip content. if (mapData != null) { GuiUtils.checkPasteEnable(mapData.getControl(), true); } // For RichEdit Ctrl, Set AcceptButton(i.e. DefaultButton) to null in order to allow enter key on RichEdit control. if (sender is MgRichTextBox) { Form form = GuiUtils.FindForm(richTextCtrl); form.AcceptButton = null; if (((MgRichTextBox)sender).ReadOnly) { GuiUtils.restoreFocus(form); } } break; case EventType.LOST_FOCUS: // Always disable paste when exiting a text ctrl. (since we might be focusing on a diff type of // ctrl). if (mapData != null) { GuiUtils.disablePaste(mapData.getControl()); } break; case EventType.KEY_UP: // Korean if (sender is MgRichTextBox && ((MgRichTextBox)sender).KoreanInterimSel >= 0) { return; } if (utilImeJpn != null) { if (utilImeJpn.IsEditingCompStr(richTextCtrl)) // JPN: IME support { return; } if (richTextCtrl is MgRichTextBox) // JPN: ZIMERead function { utilImeJpn.StrImeRead = ((MgRichTextBox)richTextCtrl).GetCompositionString(); } } GuiUtils.enableDisableEvents(sender, mapData.getControl()); return; case EventType.KEY_DOWN: // Korean if (sender is MgRichTextBox && ((MgRichTextBox)sender).KoreanInterimSel >= 0) { return; } if (utilImeJpn != null && utilImeJpn.IsEditingCompStr(richTextCtrl)) // JPN: IME support { return; } KeyEventArgs keyEventArgs = (KeyEventArgs)e; // marking the text (next/prev char or beg/end text) we let the // system to take care of it. // why ? There is no way in windows to set the caret at the beginning of // a selected text. it works only on multi mark for some reason. // also posting a shift+key does not work well since we have no way of knowing // if the shift is already pressed or not. // *** ALL other keys will continue to handleEvent. if ((keyEventArgs.Shift && (keyEventArgs.KeyCode == Keys.Left || keyEventArgs.KeyCode == Keys.Right || keyEventArgs.KeyCode == Keys.Up || keyEventArgs.KeyCode == Keys.Down || keyEventArgs.KeyCode == Keys.Home || keyEventArgs.KeyCode == Keys.End)) || (keyEventArgs.Control && (keyEventArgs.KeyCode == Keys.Left || keyEventArgs.KeyCode == Keys.Right))) { keyEventArgs.Handled = false; return; } break; case EventType.KEY_PRESS: KeyPressEventArgs keyPressEventArgs = (KeyPressEventArgs)e; bool IgnoreKeyPress = ((TagData)richTextCtrl.Tag).IgnoreKeyPress; // should we ignore the key pressed ? if (IgnoreKeyPress) { ((TagData)richTextCtrl.Tag).IgnoreKeyPress = false; return; } // skipp control key if (Char.IsControl(keyPressEventArgs.KeyChar)) { return; } int start = richTextCtrl.SelectionStart; int end = richTextCtrl.SelectionStart + richTextCtrl.SelectionLength; String pressedChar = "" + keyPressEventArgs.KeyChar; // flag the isActChar to indicate this is MG_ACT_CHAR Events.OnKeyDown(guiMgForm, ctrl, Modifiers.MODIFIER_NONE, 0, start, end, pressedChar, true, "-1", keyPressEventArgs.Handled); // keyPressEventArgs.Handled wii stay 'false' in order to let the system put the correct char. // What will happen is 2 things : 1. processKeyDown will add 'MG_ACT_CHAR'. 2. The system will write the char. // In the past, the 'ACT_CHAR' was using sendKeys in order to write the char, but it makes problems in multilanguage systems. // So, in TextMaskEditor for rich , ACT_CHAR will do nothing, just pass there in order to rais the 'control modify'. //keyPressEventArgs.Handled = true; break; case EventType.MOUSE_UP: GuiUtils.enableDisableEvents(sender, mapData.getControl()); break; } } finally { contextIDGuard.Dispose(); } DefaultHandler.getInstance().handleEvent(type, sender, e); }
/// <summary> /// Dropイベント /// </summary> /// <param name="args"></param> private void Description_DragDrop(System.Windows.DragEventArgs args) { if (args.Data.GetDataPresent(typeof(ContentModel))) { // Drop item var data = args.Data.GetData(typeof(ContentModel)) as ContentModel; // EventArgsからDrop先のFrameworkElementを取得 var feDest = args.Source as System.Windows.Controls.ListBox; // EventArgsからDrop先のバインドオブジェクトを取得 var bindDest = BindingOperations.GetBinding( (args.Source as System.Windows.Controls.ListBox), System.Windows.Controls.ListBox.ItemsSourceProperty).Path.Path; // Drop元のバインドオブジェクトを取得 var dragFromTheme = ThemeList.Any(item => item.ContentList.Contains(data)); var dragFromFree = ContentFreeList.Contains(data); // Drop元とDrop先のチェック if (bindDest == nameof(ThemeList)) { if (dragFromFree) { Point position = args.GetPosition(args.OriginalSource as IInputElement); //System.Windows.Media.VisualTreeHelper.HitTest( // this // , null // , new System.Windows.Media.HitTestResultCallback(OnHitTestResultCallback) // , new System.Windows.Media.PointHitTestParameters(position)); // Drop Index //var targetContainer = GuiUtils.GetTemplatedRootElement(args.OriginalSource as FrameworkElement); //var targetContainer2 = GuiUtils.FindAncestor<System.Windows.Controls.ListBox>(args.OriginalSource as FrameworkElement); var index = ThemeList.IndexOf(DropTarget); index = index < 0 ? feDest.Items.Count - 1 : index; //var datas = ThemeList[index].ContentList.Add(data); ContentFreeList.Remove(data); } else if (dragFromTheme) { return; } } else if (bindDest == nameof(ContentFreeList)) { if (dragFromFree) { // Drop Index var targetContainer = GuiUtils.GetTemplatedRootElement(args.OriginalSource as FrameworkElement); var index = feDest.ItemContainerGenerator.IndexFromContainer(targetContainer); index = index < 0 ? feDest.Items.Count - 1 : index; // Collectionに反映 var ocDest = this[bindDest] as ObservableCollection <ContentModel>; ocDest.Move(feDest.SelectedIndex, index); } else if (dragFromTheme) { // Drop Index var index = ThemeList .Select((thm, i) => new { Theme = thm, Index = i }) .Where(item => item.Theme.ContentList.Contains(data)) .Select(item => item.Index).FirstOrDefault(); // Collectionに反映 ContentFreeList.Add(data); ThemeList[index].ContentList.Remove(data); } } return; } if (args.Data.GetDataPresent(typeof(ThemeModel))) { return; } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { //base.OnPaint(e); Form.Skin.GraphicsCommon(e.Graphics); try { int DX = this.ClientRectangle.Width; int DY = this.ClientRectangle.Height; //e.Graphics.FillRectangle(BrushBackground, this.ClientRectangle); Form.DrawImage(e.Graphics, GuiUtils.GetResourceImage("tab_l_bg"), new Rectangle(0, 0, ClientSize.Width, ClientSize.Height)); m_chartDX = this.ClientRectangle.Width; m_chartDY = this.ClientRectangle.Height - m_legendDY; m_chartStartX = 0; m_chartStartY = m_chartDY; float maxY = m_chart.GetMax(); if (maxY <= 0) { maxY = 4096; } else if (maxY > 1000000000000) { maxY = 1000000000000; } Point lastPointDown = new Point(-1, -1); Point lastPointUp = new Point(-1, -1); float stepX = (m_chartDX - 0) / m_chart.Resolution; // Grid lines for (int g = 0; g < m_chart.Grid; g++) { float x = ((m_chartDX - 0) / m_chart.Grid) * g; e.Graphics.DrawLine(m_penGrid, m_chartStartX + x, 0, m_chartStartX + x, m_chartStartY); } // Axis line e.Graphics.DrawLine(Pens.Gray, 0, m_chartStartY, m_chartDX, m_chartStartY); // Legend /* * { * string legend = ""; * legend += Messages.ChartRange + ": " + Utils.FormatSeconds(m_chart.Resolution * m_chart.TimeStep); * legend += " "; * legend += Messages.ChartGrid + ": " + Utils.FormatSeconds(m_chart.Resolution / m_chart.Grid * m_chart.TimeStep); * legend += " "; * legend += Messages.ChartStep + ": " + Utils.FormatSeconds(m_chart.TimeStep); * * Point mp = Cursor.Position; * mp = PointToClient(mp); * if ((mp.X > 0) && (mp.Y < chartDX) && (mp.Y > chartDY) && (mp.Y < DY)) * legend += " - " + Messages.ChartClickToChangeResolution; * * e.Graphics.DrawString(legend, FontLabel, BrushLegendText, ChartRectangle(0, chartStartY, chartDX, m_legendDY), formatTopCenter); * } */ // Graph for (int i = 0; i < m_chart.Resolution; i++) { int p = i + m_chart.Pos + 1; if (p >= m_chart.Resolution) { p -= m_chart.Resolution; } float downY = ((m_chart.Download[p]) * (m_chartDY - m_marginTopY)) / maxY; float upY = ((m_chart.Upload[p]) * (m_chartDY - m_marginTopY)) / maxY; Point pointDown = ChartPoint(m_chartStartX + stepX * i, m_chartStartY - downY); Point pointUp = ChartPoint(m_chartStartX + stepX * i, m_chartStartY - upY); //e.Graphics.DrawLine(Pens.Green, new Point(0,0), point); if (lastPointDown.X != -1) { e.Graphics.DrawLine(m_penDownloadGraph, lastPointDown, pointDown); e.Graphics.DrawLine(m_penUploadGraph, lastPointUp, pointUp); } lastPointDown = pointDown; lastPointUp = pointUp; } // Download line float downCurY = 0; { long v = m_chart.GetLastDownload(); downCurY = ((v) * (m_chartDY - m_marginTopY)) / maxY; e.Graphics.DrawLine(m_penDownloadLine, 0, m_chartStartY - downCurY, m_chartDX, m_chartStartY - downCurY); Form.DrawStringOutline(e.Graphics, Messages.ChartDownload + ": " + ValToDesc(v), FontLabel, m_brushDownloadText, ChartRectangle(0, 0, m_chartDX, m_chartStartY - downCurY), formatBottomRight); } // Upload line { long v = m_chart.GetLastUpload(); float y = ((v) * (m_chartDY - m_marginTopY)) / maxY; float dly = 0; if (Math.Abs(downCurY - y) < 10) { dly = 15; // Download and upload overwrap, distance it. } e.Graphics.DrawLine(m_penUploadLine, 0, m_chartStartY - y, m_chartDX, m_chartStartY - y); Form.DrawStringOutline(e.Graphics, Messages.ChartUpload + ": " + ValToDesc(v), FontLabel, m_brushUploadText, ChartRectangle(0, 0, m_chartDX, m_chartStartY - y - dly), formatBottomRight); } // Mouse lines { Point mp = Cursor.Position; mp = PointToClient(mp); if ((mp.X > 0) && (mp.Y < m_chartDX) && (mp.Y > 0) && (mp.Y < m_chartDY)) { e.Graphics.DrawLine(m_penMouse, 0, mp.Y, m_chartDX, mp.Y); e.Graphics.DrawLine(m_penMouse, mp.X, 0, mp.X, m_chartDY); float i = (m_chartDX - (mp.X - m_chartStartX)) / stepX; int t = Conversions.ToInt32(i * m_chart.TimeStep); //float y = mp.Y * maxY / (chartDY - m_marginTopY); float y = (m_chartStartY - (mp.Y - m_marginTopY)) * maxY / m_chartDY; String label = ValToDesc(Conversions.ToInt64(y)) + ", " + Utils.FormatSeconds(t) + " ago"; StringFormat formatAlign = formatBottomLeft; Rectangle rect = new Rectangle(); //if(DX - mp.X > DX / 2) if (mp.X < DX - 150) { //if (DY - mp.Y > DY / 2) if (mp.Y < 20) { formatAlign = formatTopLeft; rect.X = mp.X + 20; rect.Y = mp.Y + 5; rect.Width = DX; rect.Height = DX; } else { formatAlign = formatBottomLeft; rect.X = mp.X + 20; rect.Y = 0; rect.Width = DX; rect.Height = mp.Y - 5; } } else { //if (DY - mp.Y > DY / 2) if (mp.Y < 20) { formatAlign = formatTopRight; rect.X = 0; rect.Y = mp.Y; rect.Width = mp.X - 20; rect.Height = DY; } else { formatAlign = formatBottomRight; rect.X = 0; rect.Y = 0; rect.Width = mp.X - 20; rect.Height = mp.Y - 5; } } Form.DrawStringOutline(e.Graphics, label, FontLabel, m_brushMouse, rect, formatAlign); } } } catch (Exception ex) { Debug.Trace(ex); } }
internal override string getSpecificControlValue() { return(GuiUtils.getCheckBoxValue(CheckState)); }
private void OnPatchVisibilityChange(DataLayer dataLayer, Patch patch, bool visible) { if (visible) { if (TryGetLogo(patch, out string patchLogoURLs)) { var matches = CsvHelper.regex.Matches(patchLogoURLs); if (matches.Count > 0) { var logoURLs = new List <string>(); patches.Add(patch, logoURLs); foreach (Match match in matches) { var logoURL = match.Groups[2].Value; logoURLs.Add(logoURL); if (logos.TryGetValue(logoURL, out LogoInfo info)) { info.count++; } else { string dir = Path.GetDirectoryName(patch.Filename); string filename = Path.Combine(dir, logoURL); var logoTexture = new Texture2D(2, 2); logoTexture.LoadImage(File.ReadAllBytes(filename)); // This will auto-resize the texture var logoSprite = Sprite.Create(logoTexture, new Rect(0, 0, logoTexture.width, logoTexture.height), Vector2.zero, 100); var logoImage = new GameObject("Logo").AddComponent <Image>(); logoImage.preserveAspect = true; logoImage.sprite = logoSprite; logoImage.transform.SetParent(transform, false); var rt = logoImage.transform as RectTransform; rt.pivot = Vector2.one; float height = logoTexture.height; float width = logoTexture.width; if (width > maxLogoWidth) { height = maxLogoWidth * height / width; width = maxLogoWidth; } rt.sizeDelta = new Vector2(width, Mathf.Min(maxLogoHeight, height)); info = new LogoInfo(logoImage.gameObject); logos.Add(logoURL, info); } } } } } else { if (patches.TryGetValue(patch, out List <string> patchLogos)) { patches.Remove(patch); foreach (var patchLogo in patchLogos) { var info = logos[patchLogo]; info.count--; if (info.count == 0) { logos.Remove(patchLogo); Destroy(info.go); } } } } GuiUtils.RebuildLayout(transform); }
public override void OnListViewDrawSubItem(object sender, DrawListViewSubItemEventArgs e) { base.OnListViewDrawSubItem(sender, e); if (Visible == false) { return; } if (e.ColumnIndex == 1) { Controls.ListViewItemServer listItemServer = e.Item as Controls.ListViewItemServer; float part = listItemServer.Info.ScorePerc(); Image imageN = GuiUtils.GetResourceImage("stars_n"); Image imageH = GuiUtils.GetResourceImage("stars_h"); Rectangle sourceH = new Rectangle(0, 0, Convert.ToInt32(Convert.ToDouble(imageH.Width) * part), imageH.Height); Form.DrawImageContain(e.Graphics, imageN, e.Bounds, 0); Form.DrawImageContain(e.Graphics, imageH, e.Bounds, 0, sourceH); } else if (e.ColumnIndex == 4) { Controls.ListViewItemServer listItemServer = e.Item as Controls.ListViewItemServer; Rectangle R1 = e.Bounds; R1.Inflate(-2, -2); /* * Int64 bwCur = 2*(listItemServer.Info.Bandwidth*8)/(1000*1000); // to Mbit/s * Int64 bwMax = listItemServer.Info.BandwidthMax; * * float p = (float)bwCur / (float)bwMax; */ String label = listItemServer.Info.GetLoadForList(); float p = listItemServer.Info.GetLoadPercForList(); string color = listItemServer.Info.GetLoadColorForList(); Brush b = Brushes.LightGreen; if (color == "red") { b = Brushes.LightPink; } else if (color == "yellow") { b = Brushes.LightYellow; } else { b = Brushes.LightGreen; } int W = Convert.ToInt32(p * R1.Width); if (W > R1.Width) { W = R1.Width; } //e.Graphics.FillRectangle(Form.Skin.BarBrush, new Rectangle(R1.Left, R1.Top, W, R1.Height)); Form.FillRectangle(e.Graphics, b, new Rectangle(R1.Left, R1.Top, W, R1.Height)); R1.Height -= 1; //e.Graphics.DrawRectangle(m_loadPen, R1); Form.DrawString(e.Graphics, label, e.Item.Font, Form.Skin.ForeBrush, R1, GuiUtils.StringFormatCenterMiddle); } }
private void SelectNodeMI_Click(object sender, EventArgs e) { try { ReferenceDescription reference = new SelectNodeDlg().ShowDialog(m_browser, ObjectTypes.BaseEventType); if (reference != null) { Node node = m_session.NodeCache.Find(reference.NodeId) as Node; if (node == null) { return; } ContentFilterElement element = null; // build the relative path. QualifiedNameCollection browsePath = new QualifiedNameCollection(); NodeId typeId = m_session.NodeCache.BuildBrowsePath(node, browsePath); switch (node.NodeClass) { case NodeClass.Variable: { IVariable variable = node as IVariable; if (variable == null) { break; } // create attribute operand. SimpleAttributeOperand attribute = new SimpleAttributeOperand( m_session.FilterContext, typeId, browsePath); // create default value. object value = GuiUtils.GetDefaultValue(variable.DataType, variable.ValueRank); // create attribute filter. element = m_filter.Push(FilterOperator.Equals, attribute, value); break; } case NodeClass.Object: { // create attribute operand. SimpleAttributeOperand attribute = new SimpleAttributeOperand( m_session.FilterContext, typeId, browsePath); attribute.AttributeId = Attributes.NodeId; // create attribute filter. element = m_filter.Push(FilterOperator.IsNull, attribute); break; } case NodeClass.ObjectType: { element = m_filter.Push(FilterOperator.OfType, node.NodeId); break; } default: { throw new ArgumentException("Selected an invalid node."); } } // add element. if (element != null) { AddItem(element); AdjustColumns(); } } } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
protected override void OnPatchVisibilityChange(DataLayer dataLayer, Patch patch, bool visible) { base.OnPatchVisibilityChange(dataLayer, patch, visible); bool rebuildLayout = false; if (visible) { if (AllPatchesHaveSameCategories()) { if (toggles.Count == 0) { UpdateList(); rebuildLayout = true; } else { if (patch is GridPatch) { (patch as GridPatch).SetCategoryFilter(newFilter); } else if (patch is MultiGridPatch) { (patch as MultiGridPatch).SetCategoryFilter(newFilter); } } } else { ClearList(); rebuildLayout = true; } if (patch.Data is GridData) { (patch.Data as GridData).OnGridChange += OnGridChange; } else if (patch.Data is MultiGridData) { (patch.Data as MultiGridData).OnGridChange += OnMultiGridChange; } } else { if (dataLayer.HasLoadedPatchesInView() && AllPatchesHaveSameCategories()) { if (toggles.Count == 0) { UpdateList(); rebuildLayout = true; } } else { ClearList(); rebuildLayout = true; } if (patch.Data is GridData) { (patch.Data as GridData).OnGridChange -= OnGridChange; } else if (patch.Data is MultiGridData) { (patch.Data as MultiGridData).OnGridChange -= OnMultiGridChange; } } if (rebuildLayout) { GuiUtils.RebuildLayout(transform); } }
// // Event Methods // private void OnToggleChange(bool isOn) { container.gameObject.SetActive(isOn); GuiUtils.RebuildLayout(container); }
public override void OnApplySkin() { base.OnApplySkin(); GuiUtils.FixHeightVs(lblProvider, cboProvider); }
/// <summary> /// Displays the target of a browse operation in the control. /// </summary> private void Browse(NodeId startId) { if (m_browser == null || NodeId.IsNull(startId)) { Clear(); return; } List <ItemData> variables = new List <ItemData>(); // browse the references from the node and build list of variables. BeginUpdate(); foreach (ReferenceDescription reference in m_browser.Browse(startId)) { Node target = m_session.NodeCache.Find(reference.NodeId) as Node; if (target == null) { continue; } ReferenceTypeNode referenceType = m_session.NodeCache.Find(reference.ReferenceTypeId) as ReferenceTypeNode; Node typeDefinition = null; if ((target.NodeClass & (NodeClass.Variable | NodeClass.Object)) != 0) { typeDefinition = m_session.NodeCache.Find(reference.TypeDefinition) as Node; } else { typeDefinition = m_session.NodeCache.Find(m_session.NodeCache.TypeTree.FindSuperType(target.NodeId)) as Node; } ItemData item = new ItemData(referenceType, !reference.IsForward, target, typeDefinition); AddItem(item, GuiUtils.GetTargetIcon(m_browser.Session, reference), -1); if ((target.NodeClass & (NodeClass.Variable | NodeClass.VariableType)) != 0) { variables.Add(item); } } EndUpdate(); // read the current value for any variables. if (variables.Count > 0) { ReadValueIdCollection nodesToRead = new ReadValueIdCollection(); foreach (ItemData item in variables) { ReadValueId valueId = new ReadValueId(); valueId.NodeId = item.Target.NodeId; valueId.AttributeId = Attributes.Value; valueId.IndexRange = null; valueId.DataEncoding = null; nodesToRead.Add(valueId); } DataValueCollection values; DiagnosticInfoCollection diagnosticInfos; m_session.Read( null, 0, TimestampsToReturn.Neither, nodesToRead, out values, out diagnosticInfos); ClientBase.ValidateResponse(values, nodesToRead); ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToRead); for (int ii = 0; ii < variables.Count; ii++) { variables[ii].Value = values[ii]; foreach (ListViewItem item in ItemsLV.Items) { if (Object.ReferenceEquals(item.Tag, variables[ii])) { UpdateItem(item, variables[ii]); break; } } } } }
/// <summary> /// Processes a Publish response from the server. /// </summary> /// void ItemNotification(MonitoredItem monitoredItem, MonitoredItemNotificationEventArgs e) { if (InvokeRequired) { BeginInvoke(new MonitoredItemNotificationEventHandler(ItemNotification), monitoredItem, e); return; } else if (!IsHandleCreated) { return; } try { if (monitoredItem != null) { string Key = monitoredItem.StartNodeId.Identifier.ToString() + "." + monitoredItem.RelativePath; ListViewItem[] lvis = listView1.Items.Find(Key, true); Opc.Ua.MonitoredItemNotification change = e.NotificationValue as Opc.Ua.MonitoredItemNotification; if (change != null) { DataValue dv = change.Value; if (lvis.Length == 1) { ListViewItem lvi = lvis[0]; int subindex = lvi.SubItems.IndexOfKey(Key); ListViewItem.ListViewSubItem si = lvi.SubItems[subindex]; TypedMonitoredItem mi = si.Tag as TypedMonitoredItem; if (mi != null) { if (mi.ClientHandle == monitoredItem.ClientHandle) { if (dv != null && dv.Value != null) { if (monitoredItem.Status.Id == StatusCodes.BadNodeIdUnknown) { // Randy said we would get this, but we don't RemoveSessionItem(lvi, true); } else { si.Text = mi.ToString(dv); } } else { // This is what we get RemoveSessionItem(lvi, true); } } else { Utils.Trace("(mi.ClientHandle != monitoredItem.ClientHandle " + MethodBase.GetCurrentMethod()); } } else { Utils.Trace("mi is null " + MethodBase.GetCurrentMethod()); } } else { Utils.Trace("lvis.Length != 1 " + MethodBase.GetCurrentMethod()); } } else { EventFieldList eventFields = e.NotificationValue as EventFieldList; if (eventFields != null) { // get the event fields. NodeId eventType = monitoredItem.GetFieldValue(eventFields, ObjectTypes.BaseEventType, BrowseNames.EventType) as NodeId; string sourceName = monitoredItem.GetFieldValue(eventFields, ObjectTypes.BaseEventType, BrowseNames.SourceName) as string; DateTime? time = monitoredItem.GetFieldValue(eventFields, ObjectTypes.BaseEventType, BrowseNames.Time) as DateTime?; ushort? severity = monitoredItem.GetFieldValue(eventFields, ObjectTypes.BaseEventType, BrowseNames.Severity) as ushort?; LocalizedText message = monitoredItem.GetFieldValue(eventFields, ObjectTypes.BaseEventType, BrowseNames.Message) as LocalizedText; NodeId sourceNode = monitoredItem.GetFieldValue(eventFields, ObjectTypes.BaseEventType, BrowseNames.SourceNode) as NodeId; //Utils.Trace("eventType: {0}, message: {1}, sourceName: {2} sourceNode: {3}", eventType.ToString(), message.Text.ToString(), sourceName.ToString(), sourceNode.ToString()); if (eventType == new NodeId(ObjectTypes.AuditActivateSessionEventType)) { Utils.Trace("AuditActivateSessionEventType detected " + MethodBase.GetCurrentMethod()); AddSessions(); m_Subscription.ModifyItems(); m_Subscription.ApplyChanges(); } } else { Utils.Trace("eventFields is null " + MethodBase.GetCurrentMethod()); } } } else { Utils.Trace("monitoredItem is null " + MethodBase.GetCurrentMethod()); } } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
void Chat_Update(ChatMessage message) { int oldStart = MessageTextBox.SelectionStart; int oldLength = MessageTextBox.SelectionLength; MessageTextBox.SelectionStart = MessageTextBox.Text.Length; MessageTextBox.SelectionLength = 0; // name, in bold, blue for incoming, red for outgoing if (message.System) { MessageTextBox.SelectionColor = Color.Black; } else if (Core.Network.Local.Equals(message)) { MessageTextBox.SelectionColor = message.Sent ? Color.Red : Color.LightCoral; } else { MessageTextBox.SelectionColor = Color.Blue; } MessageTextBox.SelectionFont = BoldFont; string prefix = " "; if (!message.System) { prefix += Chat.GetNameAndLocation(message); } if (MessageTextBox.Text.Length != 0) { prefix = "\n" + prefix; } // add timestamp if (TimestampMenu.Checked) { MessageTextBox.AppendText(prefix); MessageTextBox.SelectionFont = TimeFont; MessageTextBox.AppendText(" (" + message.TimeStamp.ToString("T") + ")"); MessageTextBox.SelectionFont = BoldFont; prefix = ""; } if (!message.System) { prefix += ": "; } MessageTextBox.AppendText(prefix); // message, grey for not acked MessageTextBox.SelectionColor = Color.Black; if (Core.Network.Local.Equals(message) && !message.Sent) { MessageTextBox.SelectionColor = Color.LightGray; } if (message.System) { MessageTextBox.SelectionFont = SystemFont; MessageTextBox.AppendText(" *" + message.Text); } else { MessageTextBox.SelectionFont = RegularFont; if (message.Format == TextFormat.RTF) { MessageTextBox.SelectedRtf = GuiUtils.RtftoColor(message.Text, MessageTextBox.SelectionColor); } else { MessageTextBox.AppendText(message.Text); } } MessageTextBox.SelectionStart = oldStart; MessageTextBox.SelectionLength = oldLength; MessageTextBox.DetectLinksDefault(); if (!MessageTextBox.Focused) { MessageTextBox.SelectionStart = MessageTextBox.Text.Length; MessageTextBox.ScrollToCaret(); } ParentView.MessageFlash(); }
private void lnkHelp_LinkClicked(object sender, EventArgs e) { GuiUtils.OpenUrl(UiClient.Instance.Data["links"]["help"]["openvpn-management"].Value as string); }
void PortTools_Load(object sender, EventArgs e) { GuiUtils.SetIcon(this); }
internal override void handleEvent(EventType type, Object sender, EventArgs e) { ControlsMap controlsMap = ControlsMap.getInstance(); UtilImeJpn utilImeJpn = Manager.UtilImeJpn; TextBox textCtrl = (TextBox)sender; int start; int end; MapData mapData = controlsMap.getMapData(textCtrl); if (mapData == null) { return; } GuiMgControl guiMgCtrl = mapData.getControl(); GuiMgForm guiMgForm = mapData.getForm(); var contextIDGuard = new Manager.ContextIDGuard(Manager.GetContextID(guiMgCtrl)); if (Events.ShouldLog(Logger.LogLevels.Gui)) { Events.WriteGuiToLog("TextBoxHandler(\"" + mapData.getControl().getName(mapData.getIdx()) + "\"): " + type); } try { switch (type) { case EventType.GOT_FOCUS: // check the paste enable. check the clip content. if (mapData != null) { GuiUtils.checkPasteEnable(mapData.getControl(), true); GuiUtils.SetFocusColor(textCtrl); } break; case EventType.LOST_FOCUS: // Always disable paste when exiting a text ctrl. (since we might be focusing on a diff type of // ctrl). if (mapData != null) { GuiUtils.disablePaste(mapData.getControl()); GuiUtils.ResetFocusColor(textCtrl); } break; case EventType.KEY_UP: GuiUtils.enableDisableEvents(sender, mapData.getControl()); return; case EventType.KEY_DOWN: KeyEventArgs keyEventArgs = (KeyEventArgs)e; if (ShouldBeHandledByTextBox(textCtrl, keyEventArgs)) { GuiUtils.checkAutoWide(mapData.getControl(), textCtrl, GuiUtils.getValue(textCtrl)); keyEventArgs.Handled = false; return; } break; case EventType.IME_EVENT: // (Korean) IME messages (WM_IME_COMPOSITION, etc.) are handled as pseudo-input // where action=MG_ACT_CHAR, text=" ". // To distinguish with real " ", ImeParam im is attached to RuntimeEvent. ImeEventArgs iea = (ImeEventArgs)e; start = textCtrl.SelectionStart; end = textCtrl.SelectionStart + textCtrl.SelectionLength; Events.OnKeyDown(guiMgForm, guiMgCtrl, Modifiers.MODIFIER_NONE, 0, start, end, " ", iea.im, true, "-1", false, iea.Handled); iea.Handled = true; break; case EventType.KEY_PRESS: KeyPressEventArgs keyPressEventArgs = (KeyPressEventArgs)e; // skipp control key if (Char.IsControl(keyPressEventArgs.KeyChar)) { return; } start = textCtrl.SelectionStart; end = textCtrl.SelectionStart + textCtrl.SelectionLength; String pressedChar = "" + keyPressEventArgs.KeyChar; // flag the isActChar to indicate this is MG_ACT_CHAR Events.OnKeyDown(guiMgForm, guiMgCtrl, Modifiers.MODIFIER_NONE, 0, start, end, pressedChar, true, "-1", keyPressEventArgs.Handled); keyPressEventArgs.Handled = true; break; case EventType.MOUSE_UP: GuiUtils.enableDisableEvents(sender, mapData.getControl()); break; case EventType.CUT: Events.CutEvent(mapData.getControl()); return; case EventType.COPY: Events.CopyEvent(mapData.getControl()); return; case EventType.PASTE: Events.PasteEvent(mapData.getControl()); return; case EventType.CLEAR: Events.ClearEvent(mapData.getControl()); return; case EventType.UNDO: Events.UndoEvent(mapData.getControl()); return; case EventType.STATUS_TEXT_CHANGED: // JPN: ZIMERead function if (utilImeJpn != null && sender is MgTextBox && !utilImeJpn.IsEditingCompStr((Control)sender)) { utilImeJpn.StrImeRead = ((MgTextBox)sender).GetCompositionString(); } return; } } finally { contextIDGuard.Dispose(); } DefaultHandler.getInstance().handleEvent(type, sender, e); }
void linkHelpForward_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { GuiUtils.OpenBrowser("https://portforward.com"); }
void TestClient_ReportTestProgress(object sender, ServerTestClient.ReportProgressEventArgs e) { if (InvokeRequired) { this.Invoke(new EventHandler <ServerTestClient.ReportProgressEventArgs>(TestClient_ReportTestProgress), sender, e); return; } try { if (this.Test_NoDisplayUpdateMI.Checked) { return; } e.Stop = !m_running; if (!m_running) { return; } TestsCompletedTB.Text = Utils.Format( "{0} ({1} Failed)", e.TestCount, e.FailedTestCount); EndpointTB.Text = Utils.Format( "{0} of {1} [{2}:{3}:{4}:{5}]", e.EndpointCount, e.TotalEndpointCount, e.Endpoint.EndpointUrl.Scheme, e.Endpoint.Description.SecurityMode, SecurityPolicies.GetDisplayName(e.Endpoint.Description.SecurityPolicyUri), (e.Endpoint.Configuration.UseBinaryEncoding)?"Binary":"XML"); IterationTB.Text = Utils.Format( "{0} of {1}", e.IterationCount, e.TotalIterationCount); TestCaseTB.Text = Utils.Format("{0}/{1}", e.Testcase.Parent, e.Testcase.Name); if (e.Breakpoint) { DialogResult result = MessageBox.Show( "Stopped at breakpoint. Continue?", e.Testcase.Name, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); e.Stop = result != DialogResult.OK; return; } double progress = (e.CurrentProgress / e.FinalProgress) * (TestCaseProgressCTRL.Maximum - TestCaseProgressCTRL.Minimum); if (progress < TestCaseProgressCTRL.Minimum) { progress = TestCaseProgressCTRL.Minimum; } if (progress > TestCaseProgressCTRL.Maximum) { progress = TestCaseProgressCTRL.Maximum; } TestCaseProgressCTRL.Value = (int)progress; } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
private void EncodingCB_SelectedIndexChanged(object sender, EventArgs e) { try { DescriptionTB.Text = null; TypeNameTB.Text = null; DictionaryNameTB.Text = null; TypeSystemNameTB.Text = null; if (EncodingCB.SelectedIndex < 0 || EncodingCB.SelectedIndex > m_encodings.Count) { return; } // get the current encoding. ReferenceDescription encoding = m_encodings[EncodingCB.SelectedIndex]; // find the desctiption. ReferenceDescription description = m_session.FindDataDescription((NodeId)encoding.NodeId); if (description == null) { return; } TypeNameTB.Text = description.ToString(); // find the dictionary. DataDictionary dictionary = m_session.FindDataDictionary((NodeId)description.NodeId); if (dictionary == null) { return; } NodeId descriptionId = null; if (!ShowEntireDictionaryCHK.Checked) { descriptionId = (NodeId)description.NodeId; } DictionaryNameTB.Text = dictionary.Name; TypeSystemNameTB.Text = dictionary.TypeSystemName; DescriptionTB.Text = dictionary.GetSchema(descriptionId); Cursor = Cursors.WaitCursor; try { FormatDescription(); } finally { Cursor = Cursors.Default; } } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
private void OkBTN_Click(object sender, EventArgs e) { try { string storeType = null; string storePath = null; string domainName = null; string organization = null; string subjectName = SubjectNameTB.Text.Trim(); string issuerKeyFilePath = IssuerKeyFilePathTB.Text.Trim(); string issuerKeyFilePassword = IssuerPasswordTB.Text.Trim(); if (String.IsNullOrEmpty(issuerKeyFilePath)) { throw new ApplicationException("Must provide an issuer certificate."); } // verify certificate. X509Certificate2 issuer = new X509Certificate2( issuerKeyFilePath, issuerKeyFilePassword, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet); if (!issuer.HasPrivateKey) { throw new ApplicationException("Issuer certificate does not have a private key."); } // determine certificate type. foreach (X509Extension extension in issuer.Extensions) { X509BasicConstraintsExtension basicContraints = extension as X509BasicConstraintsExtension; if (basicContraints != null) { if (!basicContraints.CertificateAuthority) { throw new ApplicationException("Certificate cannot be used to issue new certificates."); } } } // check traget store. if (!String.IsNullOrEmpty(CertificateStoreCTRL.StorePath)) { storeType = CertificateStoreCTRL.StoreType; storePath = CertificateStoreCTRL.StorePath; } if (String.IsNullOrEmpty(storePath)) { throw new ApplicationException("Please specify a store path."); } domainName = DomainNameTB.Text; organization = OrganizationTB.Text; // extract key fields from the subject name. if (SubjectNameCK.Checked) { List <string> parts = Utils.ParseDistinguishedName(SubjectNameTB.Text); for (int ii = 0; ii < parts.Count; ii++) { if (parts[ii].StartsWith("CN=")) { domainName = parts[ii].Substring(3).Trim(); } if (parts[ii].StartsWith("O=")) { organization = parts[ii].Substring(2).Trim(); } } } if (String.IsNullOrEmpty(domainName)) { throw new ApplicationException("Please specify a domain name."); } if (!String.IsNullOrEmpty(DomainNameTB.Text) && domainName != DomainNameTB.Text) { throw new ApplicationException("The domain name must be the common name for the certificate."); } if (!String.IsNullOrEmpty(OrganizationTB.Text) && organization != OrganizationTB.Text) { throw new ApplicationException("The organization must be the organization for the certificate."); } X509Certificate2 certificate = Opc.Ua.CertificateFactory.CreateCertificate( storeType, storePath, null, null, domainName, subjectName, null, Convert.ToUInt16(KeySizeCB.SelectedItem.ToString()), DateTime.MinValue, (ushort)LifeTimeInMonthsUD.Value, 0, false, false, issuerKeyFilePath, issuerKeyFilePassword); m_certificate = new CertificateIdentifier(); m_certificate.StoreType = storeType; m_certificate.StorePath = storePath; m_certificate.Certificate = certificate; try { CertificateStoreIdentifier rootStore = new CertificateStoreIdentifier(); rootStore.StoreType = CertificateStoreType.Windows; rootStore.StorePath = "LocalMachine\\Root"; using (ICertificateStore store = rootStore.OpenStore()) { X509Certificate2 rootCertificate = new X509Certificate2(issuerKeyFilePath, issuerKeyFilePassword, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet); if (store.FindByThumbprint(rootCertificate.Thumbprint) == null) { if (Ask("Would you like to install the signing certificate as a trusted root authority on this machine?")) { store.Add(new X509Certificate2(rootCertificate.RawData)); } } } } catch (Exception exception) { GuiUtils.HandleException(this.Text, System.Reflection.MethodBase.GetCurrentMethod(), exception); } // close the dialog. DialogResult = DialogResult.OK; } catch (Exception exception) { GuiUtils.HandleException(this.Text, System.Reflection.MethodBase.GetCurrentMethod(), exception); } }