public MainWindow() { InitializeComponent(); inkCanvasLine.DefaultDrawingAttributes.Width = 0.5; inkCanvasLine.DefaultDrawingAttributes.Height = 0.5; inkCanvasCoat.DefaultDrawingAttributes.Width = 0.5; inkCanvasCoat.DefaultDrawingAttributes.Height = 0.5; inkCanvasLine.EditingMode = InkCanvasEditingMode.Ink; inkCanvasCoat.EditingMode = InkCanvasEditingMode.Ink; Console.WriteLine(WintabManager.IsWintabAvailable()); CanvasPage page_first = new CanvasPage(new StrokeCollection(), new StrokeCollection()); canvasPage.Add(page_first); widthLabel.Content = "線の太さ:" + 1; pagination = new PaginationT(pageButtonPanel); playPagesTimer.Elapsed += new ElapsedEventHandler(callback); playPagesTimer.Interval = 100; playPagesTimer.Start(); inkCanvasLine.UseCustomCursor = true; inkCanvasLine.Cursor = Cursors.Pen; inkCanvasLine.Strokes.StrokesChanged += StrokesChangedEvent; inkCanvasLine.DefaultDrawingAttributes.FitToCurve = true; copiedStrokes = new StrokeCollection(); sliderOpacity.Value = 0.2; }
public ModbusControl(PageScada ps, CanvasPage canvasPage, ModbusSer modbusSer) : base(modbusSer) { this.Focusable = false; PS = ps; CanvasPage = canvasPage; ModbusSer = modbusSer; menuItemProperties.Click += Properties; }
public ComControl(PageScada ps, CanvasPage canvasPage, ComSer comSer) : base(comSer) { this.Focusable = false; PS = ps; canvasPage = canvasPage; ComSer = comSer; menuItemProperties.Click += Properties; }
public ImageControl(PageScada ps, CanvasPage canvasPage, ImageSer imageSer) : base(imageSer) { this.Focusable = false; PS = ps; CanvasPage = canvasPage; ImageSer = imageSer; menuItemProperties.Click += Properties; }
public EthernetControl(PageScada ps, CanvasPage canvasPage, EthernetSer ethernetSer) : base(ethernetSer) { this.Focusable = false; PS = ps; CanvasPage = canvasPage; EthernetSer = ethernetSer; menuItemProperties.Click += Properties; }
public Display(PageScada ps, CanvasPage canvasPage, DisplaySer displaySer) : base(displaySer) { this.Focusable = false; PS = ps; CanvasPage = canvasPage; DisplaySer = displaySer; menuItemProperties.Click += Properties; }
public Text(PageScada ps, CanvasPage canvasPage, TextSer textSer) : base(textSer) { this.Focusable = false; PS = ps; CanvasPage = canvasPage; TextSer = textSer; menuItemProperties.Click += Properties; }
public ItemInfo SaveContent(int course_id, string new_html, string question_id, string answer_id, bool comment) { switch (type) { case "Page": CanvasPage new_page = CanvasApi.PostNewPageContent(course_id, page.url, new_html); page = new_page; break; case "Discussion": CanvasDiscussionTopic new_topic = CanvasApi.PostNewDiscussionMessage(course_id, discussion.id, new_html); discussion = new_topic; break; case "Assignment": CanvasAssignment new_assignment = CanvasApi.PostNewAssignmentDescription(course_id, assignment.id, new_html); assignment = new_assignment; break; case "Quiz": if (question_id == "") { CanvasQuiz new_quiz = CanvasApi.PostNewQuizDescription(course_id, quiz.id, new_html); quiz = new_quiz; break; } var q = quiz_questions[int.Parse(question_id)]; if (answer_id == "") { CanvasQuizQuesiton new_q = CanvasApi.PostNewQuizQuestionText(course_id, quiz.id, q.id, new_html); q = new_q; break; } if (comment) { q.answers[int.Parse(answer_id)].answer_comments = new_html; CanvasQuizQuesiton new_q = CanvasApi.PostNewQuizQuestionAnswerComment(course_id, quiz.id, q.id, q.answers); quiz_questions[int.Parse(question_id)] = new_q; } else { q.answers[int.Parse(answer_id)].html = new_html; CanvasQuizQuesiton new_q = CanvasApi.PostNewQuizQuestionAnswer(course_id, quiz.id, q.id, q.answers); quiz_questions[int.Parse(question_id)] = new_q; } break; default: break; } return(this); }
public CourseInfo(int course_id) { //Constructor for a canvas course ID number this.CourseIdOrPath = course_id; //Get the course information with API CanvasCourse course_info = CanvasApi.GetCanvasCourse(course_id); CourseName = course_info.name; CourseCode = course_info.course_code; //Need to make sure the HtmlList is initialized so we can store all of the info PageHtmlList = new List <Dictionary <string, string> >(); PageInfoList = new List <Dictionary <string, ItemInfo> >(); var options = new ParallelOptions { MaxDegreeOfParallelism = -1 }; //Begin to loop through all modules of the course Parallel.ForEach(CanvasApi.GetCanvasModules(course_id), options, module => { //Console.WriteLine(module.name); //Loop through all the items for each module Parallel.ForEach(CanvasApi.GetCanvasModuleItems(course_id, module.id), options, item => { wait_for_rate_limit: //The object to connect the item location and its HTML body Dictionary <string, string> LocationAndBody = new Dictionary <string, string>(); Dictionary <string, ItemInfo> PageInfoItem = new Dictionary <string, ItemInfo>(); if (item.url == null) { return; } PageInfoItem[item.url] = new ItemInfo(); PageInfoItem[item.url].type = item.type; //Console.WriteLine(item.title); try //This try block is just in case we are not authroized to access any of these pages { switch (item.type) { //Need to see what type of item it is to determine request needed case "Page": CanvasPage page = CanvasApi.GetCanvasPage(course_id, item.page_url); LocationAndBody[item.url] = page.body; PageInfoItem[item.url].page = page; break; case "Discussion": CanvasDiscussionTopic discussion = CanvasApi.GetCanvasDiscussionTopics(course_id, item.content_id); LocationAndBody[item.url] = discussion.message; PageInfoItem[item.url].discussion = discussion; break; case "Assignment": CanvasAssignment assignment = CanvasApi.GetCanvasAssignments(course_id, item.content_id); LocationAndBody[item.url] = assignment.description; PageInfoItem[item.url].assignment = assignment; break; case "Quiz": CanvasQuiz quiz = CanvasApi.GetCanvasQuizzes(course_id, item.content_id); LocationAndBody[item.url] = quiz.description; PageInfoItem[item.url].quiz = quiz; PageInfoItem[item.url].quiz_questions = new List <CanvasQuizQuesiton>(); try { //Quizes require more as we need to gather question and answer info //Again may be able to see basic quiz but not authorized for quiz questions, this the try block. //Loop through all questions for specific quiz int question_number = 0; foreach (CanvasQuizQuesiton question in CanvasApi.GetCanvasQuizQuesitons(course_id, item.content_id)) { PageInfoItem[item.url].quiz_questions.Add(question); Dictionary <string, string> LAndB = new Dictionary <string, string>(); LAndB[item.url + $"?question_num={question_number}"] = question.question_text; lock (PageHtmlList) { PageHtmlList.Add(LAndB); } int answer_num = 0; int answer_comment_num = 0; //Loop through all answers in the quiz foreach (CanvasQuizQuestionAnswers answer in question.answers) { Dictionary <string, string> answerDict = new Dictionary <string, string>(); answerDict[item.url + $"?question_num={question_number}&answer_num={answer_num}"] = "\n" + answer?.html; lock (PageHtmlList) { PageHtmlList.Add(answerDict); } Dictionary <string, string> commentDict = new Dictionary <string, string>(); commentDict[item.url + $"?question_num={question_number}&answer_comment={answer_comment_num}"] = "\n" + answer?.comments_html; lock (PageHtmlList) { PageHtmlList.Add(commentDict); } answer_comment_num++; answer_num++; } question_number++; } } catch (Exception e) { //Check if the exception was an unauthorized request if (e.Message.Contains("Unauthorized")) { //Console.WriteLine("ERROR: (401) Unauthorized, can not search quiz questions. Skipping..."); } else { //Console.WriteLine("{0}", e); } } break; default: //Console.WriteLine($"Not Supported:\n{item.type}"); LocationAndBody["Empty"] = null; break; } //Add the location and HTML body to the List lock (PageHtmlList) { PageHtmlList.Add(LocationAndBody); } lock (PageInfoList) { PageInfoList.Add(PageInfoItem); } } catch (Exception e) { //Check if it was unauthorized if (e.Message.Contains("Unauthorized")) { //Console.WriteLine($"ERROR: (401) Unauthorized, can not search:\n{item.title}\n{item.type}"); } else if (e.Message.Contains("403")) { Console.WriteLine($"ERROR: (403) Forbidden (Rate Limit Exceedd)"); goto wait_for_rate_limit; } else { //Console.WriteLine("{0}", e); } } }); }); }
public TabItemPage(PageScada ps) { PS = ps; CanvasPage canvasPage = new CanvasPage(this.PS, this); CanvasPage = canvasPage; MainWindow mainWindow = (MainWindow)Application.Current.MainWindow; Image imageClose = new Image(); imageClose.Source = new BitmapImage(new Uri("Images/Close16.png", UriKind.Relative)); Button close = new Button(); close.Tag = this; close.Click += CloseTabItem; close.ToolTip = "Закрыть"; close.Content = imageClose; close.Height = 16; close.Width = 16; Label lPageName = new Label(); lPageName.Content = PS.Name; ScrollViewer scroll = new ScrollViewer(); scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; scroll.SetValue(Grid.RowProperty, 0); Image insertImage = new Image(); insertImage.Source = new BitmapImage(new Uri("Images/Insert16.ico", UriKind.Relative)); Binding BindingInsert = new Binding(); BindingInsert.Source = mainWindow; BindingInsert.Path = new PropertyPath("IsBindingInsertObject"); BindingInsert.Mode = BindingMode.OneWay; MenuItem menuItemInsert = new MenuItem(); menuItemInsert.SetBinding(MenuItem.IsEnabledProperty, BindingInsert); menuItemInsert.Icon = insertImage; menuItemInsert.Click += canvasPage.Insert; menuItemInsert.Header = "Вставить"; ContextMenu contextMenuCanvas = new ContextMenu(); contextMenuCanvas.Items.Add(menuItemInsert); canvasPage.ContextMenu = contextMenuCanvas; StackPanel panelTabItem = new StackPanel(); panelTabItem.ToolTip = PS.Path; panelTabItem.Orientation = Orientation.Horizontal; panelTabItem.Children.Add(lPageName); panelTabItem.Children.Add(close); this.Header = panelTabItem; this.Content = scroll; scroll.Content = canvasPage; ((AppWPF)Application.Current).CollectionTabItemParent.Add(PS.Path, this); Page page = ((AppWPF)Application.Current).CollectionPage[PS.Path]; foreach (PipeSer pipeSer in page.CollectionPipe) { Pipe pipe = new Pipe(PS, CanvasPage, pipeSer); pipe.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { pipe.PathFigureLeftSize.StartPoint = pipeSer.LeftSize.point[0]; pipe.LineSegmentLeftSize.Point = pipeSer.LeftSize.point[1]; pipe.PathFigureRightSize.StartPoint = pipeSer.RightSize.point[0]; pipe.LineSegmentRightSize.Point = pipeSer.RightSize.point[1]; pipe.PathFigureTopSize.StartPoint = pipeSer.TopSize.point[0]; pipe.LineSegmentTopSize.Point = pipeSer.TopSize.point[1]; pipe.PathFigureDownSize.StartPoint = pipeSer.DownSize.point[0]; pipe.LineSegmentDownSize.Point = pipeSer.DownSize.point[1]; pipe.PathFigureLeftFlange.StartPoint = pipeSer.LeftFlange.point[0]; pipe.PolyLineSegmentLeftFlange.Points[0] = pipeSer.LeftFlange.point[1]; pipe.PolyLineSegmentLeftFlange.Points[1] = pipeSer.LeftFlange.point[2]; pipe.PolyLineSegmentLeftFlange.Points[2] = pipeSer.LeftFlange.point[3]; pipe.PolyLineSegmentLeftFlange.Points[3] = pipeSer.LeftFlange.point[4]; pipe.PathFigureRightFlange.StartPoint = pipeSer.RightFlange.point[0]; pipe.PolyLineSegmentRightFlange.Points[0] = pipeSer.RightFlange.point[1]; pipe.PolyLineSegmentRightFlange.Points[1] = pipeSer.RightFlange.point[2]; pipe.PolyLineSegmentRightFlange.Points[2] = pipeSer.RightFlange.point[3]; pipe.PolyLineSegmentRightFlange.Points[3] = pipeSer.RightFlange.point[4]; pipe.PathFigurePipe.StartPoint = pipeSer.Pipe.point[0]; pipe.PolyLineSegmentPipe.Points[0] = pipeSer.Pipe.point[1]; pipe.PolyLineSegmentPipe.Points[1] = pipeSer.Pipe.point[2]; pipe.PolyLineSegmentPipe.Points[2] = pipeSer.Pipe.point[3]; pipe.PolyLineSegmentPipe.Points[3] = pipeSer.Pipe.point[4]; pipe.PathFigureBorder.StartPoint = pipeSer.BorderPipe.point[0]; pipe.PolyLineSegmentBorder.Points[0] = pipeSer.BorderPipe.point[1]; pipe.PolyLineSegmentBorder.Points[1] = pipeSer.BorderPipe.point[2]; pipe.PolyLineSegmentBorder.Points[2] = pipeSer.BorderPipe.point[3]; pipe.PolyLineSegmentBorder.Points[3] = pipeSer.BorderPipe.point[4]; pipe.Diameter = (pipe.PathFigureDownSize.StartPoint.Y - pipe.PathFigureTopSize.StartPoint.Y); })); pipe.SetValue(Canvas.LeftProperty, pipeSer.Сoordinates.X); pipe.SetValue(Canvas.TopProperty, pipeSer.Сoordinates.Y); canvasPage.Children.Add(pipe); pipe.ApplyTemplate(); } foreach (Pipe90Ser pipe90Ser in page.CollectionPipe90) { Pipe90 pipe90 = new Pipe90(PS, CanvasPage, pipe90Ser); pipe90.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { pipe90.PathFigureTopLenghtSize.StartPoint = pipe90Ser.TopLenghtSize.point[0]; pipe90.LineSegmentTopLenghtSize.Point = pipe90Ser.TopLenghtSize.point[1]; pipe90.PathFigureDownLenghtSize.StartPoint = pipe90Ser.DownLenghtSize.point[0]; pipe90.LineSegmentDownLenghtSize.Point = pipe90Ser.DownLenghtSize.point[1]; pipe90.PathFigureTopSize.StartPoint = pipe90Ser.TopSize.point[0]; pipe90.LineSegmentTopSize.Point = pipe90Ser.TopSize.point[1]; pipe90.PathFigureDownSize.StartPoint = pipe90Ser.DownSize.point[0]; pipe90.LineSegmentDownSize.Point = pipe90Ser.DownSize.point[1]; pipe90.PathFigureLeftFlange.StartPoint = pipe90Ser.LeftFlange.point[0]; pipe90.PolyLineSegmentLeftFlange.Points[0] = pipe90Ser.LeftFlange.point[1]; pipe90.PolyLineSegmentLeftFlange.Points[1] = pipe90Ser.LeftFlange.point[2]; pipe90.PolyLineSegmentLeftFlange.Points[2] = pipe90Ser.LeftFlange.point[3]; pipe90.PolyLineSegmentLeftFlange.Points[3] = pipe90Ser.LeftFlange.point[4]; pipe90.PathFigureRightFlange.StartPoint = pipe90Ser.RightFlange.point[0]; pipe90.PolyLineSegmentRightFlange.Points[0] = pipe90Ser.RightFlange.point[1]; pipe90.PolyLineSegmentRightFlange.Points[1] = pipe90Ser.RightFlange.point[2]; pipe90.PolyLineSegmentRightFlange.Points[2] = pipe90Ser.RightFlange.point[3]; pipe90.PolyLineSegmentRightFlange.Points[3] = pipe90Ser.RightFlange.point[4]; pipe90.PathFigureTopImage.StartPoint = pipe90Ser.TopImage.point[0]; pipe90.PolyLineSegmentTopImage.Points[0] = pipe90Ser.TopImage.point[1]; pipe90.PolyLineSegmentTopImage.Points[1] = pipe90Ser.TopImage.point[2]; pipe90.PolyLineSegmentTopImage.Points[2] = pipe90Ser.TopImage.point[3]; pipe90.PolyLineSegmentTopImage.Points[3] = pipe90Ser.TopImage.point[4]; pipe90.PathFigureDownImage.StartPoint = pipe90Ser.DownImage.point[0]; pipe90.PolyLineSegmentDownImage.Points[0] = pipe90Ser.DownImage.point[1]; pipe90.PolyLineSegmentDownImage.Points[1] = pipe90Ser.DownImage.point[2]; pipe90.PolyLineSegmentDownImage.Points[2] = pipe90Ser.DownImage.point[3]; pipe90.PolyLineSegmentDownImage.Points[3] = pipe90Ser.DownImage.point[4]; pipe90.PathFigureLeftDownSize.StartPoint = pipe90Ser.LeftDownSize.point[0]; pipe90.LineSegmentLeftDownSize.Point = pipe90Ser.LeftDownSize.point[1]; pipe90.PathFigureRightDownSize.StartPoint = pipe90Ser.RightDownSize.point[0]; pipe90.LineSegmentRightDownSize.Point = pipe90Ser.RightDownSize.point[1]; pipe90.PathFigureBorder.StartPoint = pipe90Ser.BorderPipe90.point[0]; pipe90.PolyLineSegmentBorder.Points[0] = pipe90Ser.BorderPipe90.point[1]; pipe90.PolyLineSegmentBorder.Points[1] = pipe90Ser.BorderPipe90.point[2]; pipe90.PolyLineSegmentBorder.Points[2] = pipe90Ser.BorderPipe90.point[3]; pipe90.PolyLineSegmentBorder.Points[3] = pipe90Ser.BorderPipe90.point[4]; pipe90.Diameter = (pipe90.PathFigureDownSize.StartPoint.Y - pipe90.PathFigureTopSize.StartPoint.Y); })); pipe90.SetValue(Canvas.LeftProperty, pipe90Ser.Сoordinates.X); pipe90.SetValue(Canvas.TopProperty, pipe90Ser.Сoordinates.Y); canvasPage.Children.Add(pipe90); pipe90.ApplyTemplate(); } foreach (TextSer textSer in page.CollectionText) { Text text = new Text(PS, CanvasPage, textSer); text.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { text.PathFigureBorder.StartPoint = textSer.Border.point[0]; text.PolyLineSegmentBorder.Points[0] = textSer.Border.point[1]; text.PolyLineSegmentBorder.Points[1] = textSer.Border.point[2]; text.PolyLineSegmentBorder.Points[2] = textSer.Border.point[3]; text.PolyLineSegmentBorder.Points[3] = textSer.Border.point[4]; text.PathFigureDownSize.StartPoint = textSer.DownSize.point[0]; text.LineSegmentDownSize.Point = textSer.DownSize.point[1]; text.PathFigureLeftSize.StartPoint = textSer.LeftSize.point[0]; text.LineSegmentLeftSize.Point = textSer.LeftSize.point[1]; text.PathFigureRightSize.StartPoint = textSer.RightSize.point[0]; text.LineSegmentRightSize.Point = textSer.RightSize.point[1]; text.PathFigureTopSize.StartPoint = textSer.TopSize.point[0]; text.LineSegmentTopSize.Point = textSer.TopSize.point[1]; })); text.SetValue(Canvas.LeftProperty, textSer.Сoordinates.X); text.SetValue(Canvas.TopProperty, textSer.Сoordinates.Y); canvasPage.Children.Add(text); text.ApplyTemplate(); } foreach (DisplaySer displaySer in page.CollectionDisplay) { Display display = new Display(PS, CanvasPage, displaySer); display.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { display.PathFigureBorder.StartPoint = displaySer.Border.point[0]; display.PolyLineSegmentBorder.Points[0] = displaySer.Border.point[1]; display.PolyLineSegmentBorder.Points[1] = displaySer.Border.point[2]; display.PolyLineSegmentBorder.Points[2] = displaySer.Border.point[3]; display.PolyLineSegmentBorder.Points[3] = displaySer.Border.point[4]; display.PathFigureDownSize.StartPoint = displaySer.DownSize.point[0]; display.LineSegmentDownSize.Point = displaySer.DownSize.point[1]; display.PathFigureLeftSize.StartPoint = displaySer.LeftSize.point[0]; display.LineSegmentLeftSize.Point = displaySer.LeftSize.point[1]; display.PathFigureRightSize.StartPoint = displaySer.RightSize.point[0]; display.LineSegmentRightSize.Point = displaySer.RightSize.point[1]; display.PathFigureTopSize.StartPoint = displaySer.TopSize.point[0]; display.LineSegmentTopSize.Point = displaySer.TopSize.point[1]; })); display.SetValue(Canvas.LeftProperty, displaySer.Сoordinates.X); display.SetValue(Canvas.TopProperty, displaySer.Сoordinates.Y); canvasPage.Children.Add(display); display.ApplyTemplate(); if (display.DisplaySer.IsEthernet) { foreach (EthernetSer ethernetSer in ((AppWPF)Application.Current).CollectionEthernetSers) { if (ethernetSer.ID == displaySer.EthernetID) { if (displaySer.IsCollRec) { foreach (ItemEthernet itemEthernet in ethernetSer.CollectionItemNetRec) { if (displaySer.ItemEthernetID == itemEthernet.ID) { displaySer.ItemEthernet = itemEthernet; display.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { Binding valueBinding = new Binding(); valueBinding.Converter = new ValueItemNetConverter(displaySer.ItemEthernet); valueBinding.Source = displaySer.ItemEthernet; valueBinding.Path = new PropertyPath("Value"); display.RunBinding.SetBinding(Run.TextProperty, valueBinding); })); break; } } } if (displaySer.IsCollSend) { foreach (ItemEthernet itemEthernet in ethernetSer.CollectionItemNetSend) { if (displaySer.ItemEthernetID == itemEthernet.ID) { displaySer.ItemEthernet = itemEthernet; display.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { Binding valueBinding = new Binding(); valueBinding.Converter = new ValueItemNetConverter(displaySer.ItemEthernet); valueBinding.Source = displaySer.ItemEthernet; valueBinding.Path = new PropertyPath("Value"); display.RunBinding.SetBinding(Run.TextProperty, valueBinding); })); break; } } } } } } else if (display.DisplaySer.IsModbus) { foreach (ModbusSer modbusSer in ((AppWPF)Application.Current).CollectionModbusSers) { if (modbusSer.ID == displaySer.ModbusID) { foreach (ItemModbus itemModbus in modbusSer.CollectionItemModbus) { if (displaySer.ItemModbusID == itemModbus.ID) { displaySer.ItemModbus = itemModbus; display.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { Binding valueBinding = new Binding(); valueBinding.Converter = new ValueItemModbusConverter(displaySer.ItemModbus); valueBinding.Source = displaySer.ItemModbus; valueBinding.Path = new PropertyPath("Value"); display.RunBinding.SetBinding(Run.TextProperty, valueBinding); })); break; } } break; } } } } foreach (ImageSer imageSer in page.CollectionImage) { ImageControl imageControl = new ImageControl(PS, CanvasPage, imageSer); imageControl.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { imageControl.PathFigureBorder.StartPoint = imageSer.Border.point[0]; imageControl.PolyLineSegmentBorder.Points[0] = imageSer.Border.point[1]; imageControl.PolyLineSegmentBorder.Points[1] = imageSer.Border.point[2]; imageControl.PolyLineSegmentBorder.Points[2] = imageSer.Border.point[3]; imageControl.PolyLineSegmentBorder.Points[3] = imageSer.Border.point[4]; imageControl.PathFigureDownSize.StartPoint = imageSer.DownSize.point[0]; imageControl.LineSegmentDownSize.Point = imageSer.DownSize.point[1]; imageControl.PathFigureLeftSize.StartPoint = imageSer.LeftSize.point[0]; imageControl.LineSegmentLeftSize.Point = imageSer.LeftSize.point[1]; imageControl.PathFigureRightSize.StartPoint = imageSer.RightSize.point[0]; imageControl.LineSegmentRightSize.Point = imageSer.RightSize.point[1]; imageControl.PathFigureTopSize.StartPoint = imageSer.TopSize.point[0]; imageControl.LineSegmentTopSize.Point = imageSer.TopSize.point[1]; if (imageSer.PathImage != null) { try { BitmapImage bi = new BitmapImage(new Uri(@imageSer.PathImage, UriKind.RelativeOrAbsolute)); if (bi.PixelWidth < 10 || bi.PixelWidth < 10) { new Exception(); } imageControl.templateImage.Source = bi; } catch { imageControl.templateImage.Source = new BitmapImage(new Uri("../Images/ImageNotFound.png", UriKind.RelativeOrAbsolute)); bool rotate0 = false; bool rotate90 = false; bool rotate180 = false; bool rotate270 = false; if ((int)imageControl.RenderTransform.Value.M11 == 0 && (int)imageControl.RenderTransform.Value.M12 == -1) { rotate90 = true; } else if ((int)imageControl.RenderTransform.Value.M11 == -1 && (int)imageControl.RenderTransform.Value.M12 == 0) { rotate180 = true; } else if ((int)imageControl.RenderTransform.Value.M11 == 0 && (int)imageControl.RenderTransform.Value.M12 == 1) { rotate270 = true; } else { rotate0 = true; } if (rotate0) { SizeImage((BitmapImage)imageControl.templateImage.Source, imageControl); } else if (rotate90) { SizeImage((BitmapImage)imageControl.templateImage.Source, imageControl); } else if (rotate180) { SizeImage((BitmapImage)imageControl.templateImage.Source, imageControl); } else if (rotate270) { SizeImage((BitmapImage)imageControl.templateImage.Source, imageControl); } } } else if (imageControl.ImageSer.LibraryImage != null) { BitmapImage bi = new BitmapImage(new Uri(@"pack://application:,,,/Images/" + imageControl.ImageSer.LibraryImage + ".png", UriKind.RelativeOrAbsolute)); imageControl.templateImage.Source = bi; } else { imageControl.templateImage.Source = new BitmapImage(new Uri("../Images/ImageNotFound.png", UriKind.RelativeOrAbsolute)); bool rotate0 = false; bool rotate90 = false; bool rotate180 = false; bool rotate270 = false; if ((int)imageControl.RenderTransform.Value.M11 == 0 && (int)imageControl.RenderTransform.Value.M12 == -1) { rotate90 = true; } else if ((int)imageControl.RenderTransform.Value.M11 == -1 && (int)imageControl.RenderTransform.Value.M12 == 0) { rotate180 = true; } else if ((int)imageControl.RenderTransform.Value.M11 == 0 && (int)imageControl.RenderTransform.Value.M12 == 1) { rotate270 = true; } else { rotate0 = true; } if (rotate0) { SizeImage((BitmapImage)imageControl.templateImage.Source, imageControl); } else if (rotate90) { SizeImage((BitmapImage)imageControl.templateImage.Source, imageControl); } else if (rotate180) { SizeImage((BitmapImage)imageControl.templateImage.Source, imageControl); } else if (rotate270) { SizeImage((BitmapImage)imageControl.templateImage.Source, imageControl); } } if (imageControl.ImageSer.StretchImage == "None") { imageControl.templateImage.Stretch = Stretch.None; } else if (imageControl.ImageSer.StretchImage == "Fill") { imageControl.templateImage.Stretch = Stretch.Fill; } else if (imageControl.ImageSer.StretchImage == "Uniform") { imageControl.templateImage.Stretch = Stretch.Uniform; } else if (imageControl.ImageSer.StretchImage == "UniformToFill") { imageControl.templateImage.Stretch = Stretch.UniformToFill; } })); imageControl.SetValue(Canvas.LeftProperty, imageSer.Сoordinates.X); imageControl.SetValue(Canvas.TopProperty, imageSer.Сoordinates.Y); canvasPage.Children.Add(imageControl); imageControl.ApplyTemplate(); } foreach (EthernetSer ethernetSer in page.CollectionEthernet) { EthernetControl ethernetControl = new EthernetControl(PS, CanvasPage, ethernetSer); ((AppWPF)Application.Current).CollectionEthernetSers.Add(ethernetSer); ethernetControl.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { ethernetControl.PathFigureBorder.StartPoint = ethernetSer.Border.point[0]; ethernetControl.PolyLineSegmentBorder.Points[0] = ethernetSer.Border.point[1]; ethernetControl.PolyLineSegmentBorder.Points[1] = ethernetSer.Border.point[2]; ethernetControl.PolyLineSegmentBorder.Points[2] = ethernetSer.Border.point[3]; ethernetControl.PolyLineSegmentBorder.Points[3] = ethernetSer.Border.point[4]; ethernetControl.PathFigureDownSize.StartPoint = ethernetSer.DownSize.point[0]; ethernetControl.LineSegmentDownSize.Point = ethernetSer.DownSize.point[1]; ethernetControl.PathFigureLeftSize.StartPoint = ethernetSer.LeftSize.point[0]; ethernetControl.LineSegmentLeftSize.Point = ethernetSer.LeftSize.point[1]; ethernetControl.PathFigureRightSize.StartPoint = ethernetSer.RightSize.point[0]; ethernetControl.LineSegmentRightSize.Point = ethernetSer.RightSize.point[1]; ethernetControl.PathFigureTopSize.StartPoint = ethernetSer.TopSize.point[0]; ethernetControl.LineSegmentTopSize.Point = ethernetSer.TopSize.point[1]; })); ethernetControl.SetValue(Canvas.LeftProperty, ethernetSer.Сoordinates.X); ethernetControl.SetValue(Canvas.TopProperty, ethernetSer.Сoordinates.Y); canvasPage.Children.Add(ethernetControl); ethernetControl.ApplyTemplate(); } foreach (ComSer comSer in page.CollectionCom) { ComControl comControl = new ComControl(PS, CanvasPage, comSer); ((AppWPF)Application.Current).CollectionComSers.Add(comSer); comControl.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { comControl.PathFigureBorder.StartPoint = comSer.Border.point[0]; comControl.PolyLineSegmentBorder.Points[0] = comSer.Border.point[1]; comControl.PolyLineSegmentBorder.Points[1] = comSer.Border.point[2]; comControl.PolyLineSegmentBorder.Points[2] = comSer.Border.point[3]; comControl.PolyLineSegmentBorder.Points[3] = comSer.Border.point[4]; comControl.PathFigureDownSize.StartPoint = comSer.DownSize.point[0]; comControl.LineSegmentDownSize.Point = comSer.DownSize.point[1]; comControl.PathFigureLeftSize.StartPoint = comSer.LeftSize.point[0]; comControl.LineSegmentLeftSize.Point = comSer.LeftSize.point[1]; comControl.PathFigureRightSize.StartPoint = comSer.RightSize.point[0]; comControl.LineSegmentRightSize.Point = comSer.RightSize.point[1]; comControl.PathFigureTopSize.StartPoint = comSer.TopSize.point[0]; comControl.LineSegmentTopSize.Point = comSer.TopSize.point[1]; })); comControl.SetValue(Canvas.LeftProperty, comSer.Сoordinates.X); comControl.SetValue(Canvas.TopProperty, comSer.Сoordinates.Y); canvasPage.Children.Add(comControl); comControl.ApplyTemplate(); } foreach (ModbusSer modbusSer in page.CollectionModbus) { ModbusControl modbusControl = new ModbusControl(PS, CanvasPage, modbusSer); ((AppWPF)Application.Current).CollectionModbusSers.Add(modbusSer); modbusControl.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { modbusControl.PathFigureBorder.StartPoint = modbusSer.Border.point[0]; modbusControl.PolyLineSegmentBorder.Points[0] = modbusSer.Border.point[1]; modbusControl.PolyLineSegmentBorder.Points[1] = modbusSer.Border.point[2]; modbusControl.PolyLineSegmentBorder.Points[2] = modbusSer.Border.point[3]; modbusControl.PolyLineSegmentBorder.Points[3] = modbusSer.Border.point[4]; modbusControl.PathFigureDownSize.StartPoint = modbusSer.DownSize.point[0]; modbusControl.LineSegmentDownSize.Point = modbusSer.DownSize.point[1]; modbusControl.PathFigureLeftSize.StartPoint = modbusSer.LeftSize.point[0]; modbusControl.LineSegmentLeftSize.Point = modbusSer.LeftSize.point[1]; modbusControl.PathFigureRightSize.StartPoint = modbusSer.RightSize.point[0]; modbusControl.LineSegmentRightSize.Point = modbusSer.RightSize.point[1]; modbusControl.PathFigureTopSize.StartPoint = modbusSer.TopSize.point[0]; modbusControl.LineSegmentTopSize.Point = modbusSer.TopSize.point[1]; })); modbusControl.SetValue(Canvas.LeftProperty, modbusSer.Сoordinates.X); modbusControl.SetValue(Canvas.TopProperty, modbusSer.Сoordinates.Y); canvasPage.Children.Add(modbusControl); modbusControl.ApplyTemplate(); } }
public BaseTest() { driver = new ChromeDriver(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.FullName); canvasPage = new CanvasPage(driver); }
public SendSmsAndMail() { _LandingPage = new LandingPage(); _CanvasPage = new CanvasPage(); }