Ejemplo n.º 1
0
        public static void RegisterVertexChangeListeners(IVertex PlatformClassVertex, VertexChange action, string[] watchList)
        {
            PlatformClassVertexChangeListener listener = new PlatformClassVertexChangeListener(watchList);

            listener.PlatformClassVertex = PlatformClassVertex;
            listener.Change += action;


            PlatformClassVertex.Change += new VertexChange(listener.Listener);

            IVertex AttributeVertexes = PlatformClassVertex.GetAll(@"$Is:{$Inherits:$PlatformClass}\Selector:");

            foreach (IEdge e in AttributeVertexes)
            {
                foreach (IEdge ee in PlatformClassVertex.GetAll(e.To.Value + ":"))
                {
                    GraphUtil.AddHandlerIfDelegateListDoesNotContainsIt(ee.To, listener.Listener);

                    foreach (string metaFromWatchList in listener.WatchList)
                    {
                        if (GeneralUtil.CompareStrings(ee.Meta.Value, metaFromWatchList))
                        {
                            foreach (IEdge eee in ee.To)
                            {
                                GraphUtil.AddHandlerIfDelegateListDoesNotContainsIt(eee.To, listener.Listener);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static async Task <int> MapToggle(string mapname)
        {
            var maplist = await GetAllMapNames();

            if (!GeneralUtil.ListContainsCaseInsensitive(maplist, mapname))
            {
                return(-1);
            }
            var dbresult = await GetDataRowCollection($"SELECT Enabled FROM MapData WHERE MapName='{mapname}'");

            if (ExtractRowInfo <byte>(dbresult[0], 0) == 0)
            {
                var payload = new Dictionary <string, object>
                {
                    { "@var1", 1 }
                };
                await DBExecuteNonQuery($"UPDATE MapData SET enabled = @var1 WHERE MapName='{mapname}'", payload);

                return(0);
            }
            else
            {
                var payload = new Dictionary <string, object>
                {
                    { "@var1", 0 }
                };
                await DBExecuteNonQuery($"UPDATE MapData SET enabled = @var1 WHERE MapName='{mapname}'", payload);

                return(1);
            }
        }
        /// <summary>
        /// Called when a click event happens on a selected course
        /// </summary>
        /// <param name="mx"></param>
        /// <param name="my"></param>
        private void clickSpecificClass(int mx, int my)
        {
            if (returnButtonRect.Contains(mx, my))
            {
                state = CourseListState.ClassList;
            }

            if (enrollButtonRect.Contains(mx, my))
            {
                HttpRequester.Default.EnrollInCourse(selectedCourse.Key, (enr) =>
                {
                    if (enr.errorCode != null)
                    {
                        GeneralUtil.ShowError(enr);
                        return(false);
                    }
                    else
                    {
                        MessageBox.Show("Successfully enrolled in class.");

                        if (enr.classes?[0]?.required?.Count > 0)
                        {
                            DialogResult ans = MessageBox.Show("There are required courses that must be taken concurrently with this course: " + enr.classes?[0]?.required?.Aggregate <string>((a, b) => a + ", " + b));
                        }
                        else if (enr.classes?[0]?.recommended?.Count > 0)
                        {
                            DialogResult ans = MessageBox.Show("There are recommended courses that should be taken concurrently with this course: " + enr.classes?[0]?.recommended?.Aggregate <string>((a, b) => a + ", " + b));
                        }
                    }

                    return(true);
                });
                state = CourseListState.ClassList;
            }
        }
Ejemplo n.º 4
0
        protected void VertexChange(object sender, VertexChangeEventArgs e)
        {
            if ((sender == Vertex) && (e.Type == VertexChangeType.EdgeAdded) && (GeneralUtil.CompareStrings(e.Edge.Meta.Value, "BaseEdge")))
            {
                UpdateBaseEdge();
            }

            if ((sender == Vertex.Get("BaseEdge:")) && (e.Type == VertexChangeType.EdgeAdded) && (GeneralUtil.CompareStrings(e.Edge.Meta.Value, "To")) ||
                (sender == Vertex.Get(@"BaseEdge:\To:") && e.Type == VertexChangeType.ValueChanged))
            {
                UpdateBaseEdge();
            }

            if (sender == Vertex.Get("ZoomVisualiserContent:") && e.Type == VertexChangeType.ValueChanged)
            {
                ChangeZoomVisualiserContent();
            }

            if (sender == Vertex.Get("ShowWhiteSpace:") && e.Type == VertexChangeType.ValueChanged)
            {
                UpdateEditView();
            }

            if (sender == Vertex.Get("HighlightedLine:") && e.Type == VertexChangeType.ValueChanged)
            {
                UpdateEditView();
            }
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(nameTextBox.Text))
            {
                GeneralUtil.Error("You must give your VDF a name");
                return;
            }

            if (String.IsNullOrEmpty(pathTextBox.Text))
            {
                GeneralUtil.Error("You must give a save path for the VDF");
                return;
            }

            if (!Directory.Exists(Path.GetDirectoryName(pathTextBox.Text)))
            {
                GeneralUtil.Error("The directory where you'd like to save the VDF doesn't exist");
                return;
            }

            VDF vdf = new VDF(nameTextBox.Text);

            vdf.Save(pathTextBox.Text);

            Editor editor = new Editor(menuForm, recent);

            editor.OpenVDF(vdf);
            editor.SetPath(pathTextBox.Text);
            recent.AddItem(pathTextBox.Text);
            recent.Save();
            menuForm.RefreshRecentItems();
            editor.Show();
            closedByUser = false;
            Close();
        }
Ejemplo n.º 6
0
        public virtual void Select()
        {
            IsSelected = true;

            GeneralUtil.SetPropertyIfPresent(this.Content, "Foreground", BackgroundColor);

            Panel.SetZIndex(this, 99999);

            double left   = Canvas.GetLeft(this);
            double top    = Canvas.GetTop(this);
            double right  = left + ActualWidth;
            double bottom = top + ActualHeight;
            double width  = ActualWidth;
            double height = ActualHeight;

            AddAnchor(ClickTargetEnum.AnchorLeftTop, left - AnchorSize, top - AnchorSize);
            AddAnchor(ClickTargetEnum.AnchorMiddleTop, left - AnchorSize / 2 + width / 2, top - AnchorSize);
            AddAnchor(ClickTargetEnum.AnchorRightTop_CreateDiagramLine, right, top - AnchorSize);

            AddAnchor(ClickTargetEnum.AnchorLeftMiddle, left - AnchorSize, top - AnchorSize / 2 + height / 2);
            AddAnchor(ClickTargetEnum.AnchorRightMiddle, right, top - AnchorSize / 2 + height / 2);

            AddAnchor(ClickTargetEnum.AnchorLeftBottom, left - AnchorSize, bottom);
            AddAnchor(ClickTargetEnum.AnchorMiddleBottom, left - AnchorSize / 2 + width / 2, bottom);
            AddAnchor(ClickTargetEnum.AnchorRightBottom, right, bottom);
        }
Ejemplo n.º 7
0
        public static IVertex GetChildEdges(IVertex metaVertex)
        {
            IVertex edgeTarget = metaVertex.Get("$EdgeTarget:");

            if (edgeTarget != null && edgeTarget != metaVertex)
            {
                return(GetChildEdges(edgeTarget));
            }

            IVertex ret = m0.MinusZero.Instance.CreateTempVertex();

            foreach (IEdge e in metaVertex)
            {
                if (GeneralUtil.CompareStrings(e.Meta, "$VertexTarget"))
                {
                    ret.AddEdge(null, m0.MinusZero.Instance.Root.Get(@"System\Meta\Base\Vertex\$EdgeTarget"));
                }
                else
                if ((e.To.Value != null) && ((string)e.To.Value != "") && (((string)e.To.Value)[0] != '$') &&
                    (GeneralUtil.CompareStrings(e.Meta, "$Empty") || ((string)e.Meta.Value)[0] != '$')) // is extanded
                                                                                                        // if (e.To.Get("$VertexTarget:") != null || e.To.Get("$EdgeTarget:") != null)
                {
                    ret.AddEdge(null, e.To);
                }
            }

            return(ret);
        }
Ejemplo n.º 8
0
        protected void Data_Bind()
        {
            string tch_id = Session["account_user_id"].ToString();
            string sql1   = "SELECT student.stu_id AS `学生学号`, stu_name AS `学生姓名`, course_select_score AS `课程成绩` FROM (((course_select INNER JOIN course_schedule ON course_select.course_schedule_id = course_schedule.course_schedule_id) INNER JOIN course ON course_schedule.course_id = course.course_id) INNER JOIN teacher ON course.tch_id = teacher.tch_id) INNER JOIN student ON course_select.stu_id = student.stu_id WHERE course_schedule.course_schedule_id = '" + course_schedule_id + "' AND teacher.tch_id = '" + tch_id + "'";

            GeneralUtil.GridViewInit(GridView1, sql1);
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Gets an already connect RCON client, or makes a new one
        /// </summary>
        /// <param name="serverId">Server ID to get client for</param>
        /// <returns>RCON client</returns>
        private async Task <RCON> GetOrCreateRconClient(string serverId)
        {
            if (!_rconClients.ContainsKey(serverId))
            {
                //Validate server before adding
                var server = DatabaseUtil.GetTestServer(serverId);

                //Server cannot be null.
                if (server == null)
                {
                    throw new NullReferenceException(nameof(serverId));
                }

                var ipEndPoint = GeneralUtil.GetIpEndPointFromString(server.Address);

                var rconClient = new RCON(ipEndPoint.Address, (ushort)ipEndPoint.Port, server.RconPassword);

                _rconClients.Add(serverId, rconClient);

                rconClient.OnDisconnected += () =>
                {
                    _ = _log.LogMessage($"RCON client for `{serverId}` has been disposed.", false, color: LOG_COLOR);

                    if (_rconClients.ContainsKey(serverId))
                    {
                        _rconClients.Remove(serverId);
                    }
                };

                rconClient.OnLog += logMessage => { _ = _log.LogMessage(logMessage, color: LOG_COLOR); };
            }

            return(_rconClients[serverId]);
        }
Ejemplo n.º 10
0
        public override IEdge AddEdge(IVertex metaVertex, IVertex destVertex)
        {
            // LOG BEGIN

            /*
             * if(metaVertex==null)
             *  MinusZero.Instance.Log(3,"AddEdge", GeneralUtil.EmptyIfNull(this.Value) + " [NULL] " + GeneralUtil.EmptyIfNull(destVertex.Value));
             * else
             *  MinusZero.Instance.Log(3,"AddEdge", GeneralUtil.EmptyIfNull(this.Value) + " [" + GeneralUtil.EmptyIfNull(metaVertex.Value) + "] " + GeneralUtil.EmptyIfNull(destVertex.Value));
             */
            // LOG END

            if (destVertex == null)
            {
                throw new Exception("target vertex can not be null");
            }

            EdgeBase ne = new EasyEdge(this, metaVertex, destVertex);

            OutEdgesRaw.Add(ne);

            UsageCounter++;

            if (GeneralUtil.CompareStrings(ne.Meta.Value, "$Inherits"))
            {
                InheritanceCount++;

                HasInheritance = true;
            }

            FireChange(new VertexChangeEventArgs(VertexChangeType.EdgeAdded, ne));

            return(ne);
        }
Ejemplo n.º 11
0
        public override void DeleteEdge(IEdge _edge)
        {
            IEdge edge = null;

            foreach (IEdge e in OutEdgesRaw)
            {
                if (e.Meta == _edge.Meta && e.To == _edge.To)
                {
                    edge = e;
                }
            }

            if (edge != null)
            {
                OutEdgesRaw.Remove(edge);

                UsageCounter--;

                if (GeneralUtil.CompareStrings(edge.Meta.Value, "$Inherits"))
                {
                    InheritanceCount--;

                    if (InheritanceCount == 0)
                    {
                        HasInheritance = false;
                    }
                }

                FireChange(new VertexChangeEventArgs(VertexChangeType.EdgeRemoved, edge));

                edge.To.DeleteInEdge(edge);
            }
            //else // becouse of inheritance this may happen
            //throw new Exception(_edge.Meta + " : " + _edge.To + " edge does not exist in given Vertex");
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> OnPostUpdate(DateTime ViewBookTime,
                                                       int ViewPallets, int ViewPort, int ActualArrivalHour,
                                                       int ActualArrivalMinute, int startHour, int startMinute,
                                                       int endHour, int endMinute, Guid ViewBookingId)
        {
            var booking = new BookingViewModel
            {
                BookingTime   = ViewBookTime,
                TotalPallets  = ViewPallets,
                Port          = ViewPort,
                ActualArrival = GeneralUtil.TimeFromHourAndMinute(ActualArrivalHour, ActualArrivalMinute),
                StartLoading  = GeneralUtil.TimeFromHourAndMinute(startHour, startMinute),
                EndLoading    = GeneralUtil.TimeFromHourAndMinute(endHour, endMinute),
                InternalId    = ViewBookingId
            };

            var result = await BookingDataService.UpdateBooking(CreateUpdateBookingCommand(booking));

            if (result.IsSuccesfull)
            {
                return(new RedirectToPageResult("ReservedBookings"));
            }

            return(new RedirectToPageResult("Error"));
        }
Ejemplo n.º 13
0
 public static void AddHandlerIfDelegateListDoesNotContainsIt(IVertex baseVertex, VertexChange _delegate)
 {
     if (baseVertex != null && !GeneralUtil.DoDelegateListContainDelegate(baseVertex.GetChangeDelegateInvocationList(), _delegate))
     {
         baseVertex.Change += _delegate;
     }
 }
Ejemplo n.º 14
0
        private async Task <RCON> GetOrCreateRconClient(string serverID)
        {
            if (!_rconClients.ContainsKey(serverID))
            {
                var server = await DatabaseModule.GetTestServerInfo(serverID);

                if (server == null)
                {
                    throw new NullReferenceException(nameof(serverID));
                }

                var ipEndPoint = GeneralUtil.GetIpEndPointFromString(server.Address);

                var rconClient = new RCON(ipEndPoint.Address, (ushort)ipEndPoint.Port, server.RconPassword);

                _rconClients.Add(serverID, rconClient);

                rconClient.OnDisconnected += () =>
                {
                    Console.WriteLine($"RCON client for `{serverID}` has been disposed.");
                    if (_rconClients.ContainsKey(serverID))
                    {
                        _rconClients.Remove(serverID);
                    }
                };

                rconClient.OnLog += logMessage =>
                {
                    Console.WriteLine($"RCON: {logMessage}");
                };
            }
            return(_rconClients[serverID]);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Compiles CS Extension into Assembly given a resource file
        /// TODO: compiler options
        /// </summary>
        /// <param name="resource"></param>
        internal static string ModeCSCompile(String resource)
        {
            String csxCode = "";

            Console.WriteLine("Compiling Extension fron File resource {0}", resource);
            String assemblyPath = String.Empty;

            // Local FS load
            if (File.Exists(resource))
            {
                try
                {
                    csxCode = File.ReadAllText(resource);
                    String compoptions = "/optimize";

                    assemblyPath = DynCSharpRunner.CompileSource(csxCode, false, false, compoptions);
                }
                catch (Exception fex)
                {
                    GeneralUtil.Usage(fex.Message);
                }
            }
            else
            {
                GeneralUtil.Usage("Check file location: " + resource);
            }
            return(assemblyPath);
        }
Ejemplo n.º 16
0
        private void VertexUpdated()
        {
            if (Vertex.Get(@"Definition:Inheritence") != null) // not to display $Inherits
            {
                return;
            }

            if (Vertex.Get(@"BaseEdge:\Meta:\$VertexTarget:") != null &&
                !GraphUtil.GetValueAndCompareStrings(Vertex.Get(@"Definition:\CreateEdgeOnly:"), "True"))
            {
                IVertex v = Vertex.Get(@"BaseEdge:\To:");
                if (v.Value != null && !GeneralUtil.CompareStrings(v.Value, "$Empty"))
                {
                    Label.Text = (string)v.Value;
                }
            }
            else
            {
                IVertex v = Vertex.Get(@"BaseEdge:\Meta:");
                if (v.Value != null && !GeneralUtil.CompareStrings(v.Value, "$Empty"))
                {
                    Label.Text = (string)v.Value;
                }
            }
        }
Ejemplo n.º 17
0
        public SrcdsLogService(DataService dataService, RconService rconService, LogHandler logHandler)
        {
            //Setup vars
            _rconService = rconService;
            _dataService = dataService;
            _logHandler  = logHandler;
            _port        = _dataService.RSettings.ProgramSettings.ListenPort;

            Console.WriteLine("Setting up SRCDS Log Service...");

            //Need to map servers
            var servers = DatabaseUtil.GetAllTestServers();

            foreach (var server in servers)
            {
                _serverIdDictionary.Add(GeneralUtil.GetIpEndPointFromString(server.Address), server);
            }

            var oldSessions = DatabaseUtil.GetAllFeedbackFiles();

            //Re-add old sessions.
            foreach (var session in oldSessions)
            {
                Console.WriteLine($"Re-adding FB sessions for: {session.ServerAddress}");
                _feedbackFiles.Add(new FeedbackFile(session, _rconService));
            }

            Start();
        }
Ejemplo n.º 18
0
        private void VertexChange(object sender, VertexChangeEventArgs e)
        {
            if ((sender == Vertex.Get(@"BaseEdge:\To:") || sender == Vertex.Get(@"BaseEdge:\Meta:")) &&
                e.Type == VertexChangeType.ValueChanged)
            {
                VertexUpdated();
            }

            if ((e.Type == VertexChangeType.EdgeAdded && (GeneralUtil.CompareStrings(e.Edge.Meta.Value, "IsDashed") || GeneralUtil.CompareStrings(e.Edge.Meta.Value, "LineWidth"))) ||
                (e.Type == VertexChangeType.ValueChanged && (sender == Vertex.Get(@"IsDashed:") || sender == Vertex.Get(@"LineWidth:"))))
            {
                UpdateLine();
            }

            if ((e.Type == VertexChangeType.EdgeAdded && (GeneralUtil.CompareStrings(e.Edge.Meta.Value, "StartAnchor") || GeneralUtil.CompareStrings(e.Edge.Meta.Value, "EndAnchor"))) ||
                (e.Type == VertexChangeType.ValueChanged && (sender == Vertex.Get(@"StartAnchor:") || sender == Vertex.Get(@"EndAnchor:"))))
            {
                UpdateLineEnds();
            }

            if ((e.Type == VertexChangeType.EdgeAdded && (GeneralUtil.CompareStrings(e.Edge.Meta.Value, "BackgroundColor") || GeneralUtil.CompareStrings(e.Edge.Meta.Value, "ForegroundColor"))) ||
                (e.Type == VertexChangeType.ValueChanged && (
                     sender == Vertex.Get(@"BackgroundColor:") || sender == Vertex.Get(@"BackgroundColor:\Red:") || sender == Vertex.Get(@"BackgroundColor:\Green:") || sender == Vertex.Get(@"BackgroundColor:\Blue:") || sender == Vertex.Get(@"BackgroundColor:\Opacity:") ||
                     sender == Vertex.Get(@"ForegroundColor:") || sender == Vertex.Get(@"ForegroundColor:\Red:") || sender == Vertex.Get(@"ForegroundColor:\Green:") || sender == Vertex.Get(@"ForegroundColor:\Blue:") || sender == Vertex.Get(@"ForegroundColor:\Opacity:")
                     )))
            {
                UpdateLineEnds();
            }
        }
        /// <summary>
        /// What happens when the user clicks the Add Previous button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddPreviousCourseBtn_Click(object sender, EventArgs e)
        {
            string tmp = PreviousCourseIdTxt.Text.ToUpper();

            if (!Regex.IsMatch(tmp, @"[A-Z][A-Z][A-Z][A-Z]?-[0-9][0-9][0-9]L?"))
            {
                MessageBox.Show("Invalid course code");
                return;
            }

            HttpRequester.Default.AddPreviousCourse(tmp, CourseNameTxt.Text.ToLower(), (int)CreditsUpDown.Value, (SuccessResponse succ) =>
            {
                if (succ.errorCode != null)
                {
                    GeneralUtil.ShowError(succ);
                    return(false);
                }

                if (succ.success == 1)
                {
                    MessageBox.Show("Successfully added previous course.");
                    List <PreviousCourse> pCourses = HttpRequester.Default.GetPreviousCourses();
                    PreviousCourseView.SetCourses(pCourses);
                }
                return(true);
            });
        }
Ejemplo n.º 20
0
        public VertexBase(IStore _Store)
        {
            UsageCounter = 0;

            _store       = _Store;
            _AccessLevel = GeneralUtil.CreateAndCopyList <AccessLevelEnum>(_store.AccessLevel);
        }
Ejemplo n.º 21
0
        private void FillNewVertexAndEdgeBySchemaMenu()
        {
            IVertex baseVertex = Edge.Get(@"To:");

            IVertex r = baseVertex.GetAll(@"$Is:");

            if (r.Count() == 0)
            {
                r = Edge.GetAll(@"Meta:");
            }
            ;

            if (r.Count() == 0 || r.FirstOrDefault().To.Value == null || GeneralUtil.CompareStrings(r.FirstOrDefault().To.Value, "$Empty"))
            {
                NewVertexBySchema.IsEnabled = false;
                NewEdgeBySchema.IsEnabled   = false;
                return;
            }

            NewVertexBySchema.Items.Clear();
            NewEdgeBySchema.Items.Clear();

            foreach (IEdge e in r)
            {
                NewVertexAndEdgeBySchema_FillForMeta(baseVertex, e.To, VertexOperations.GetChildEdges(e.To));
            }

            NewVertexAndEdgeBySchema_FillForMeta(baseVertex, MinusZero.Instance.Root.Get(@"System\Meta\Base\Vertex"), MinusZero.Instance.Root.GetAll(@"System\Meta\Base\Vertex\"));

            NewVertexBySchema.IsEnabled = true;
            NewEdgeBySchema.IsEnabled   = true;
        }
Ejemplo n.º 22
0
        public static IVertex Open(IVertex baseVertex, IVertex inputVertex)
        {
            IVertex DefaultVis;

            DefaultVis = baseVertex.Get(@"Meta:\$DefaultOpenVisualiser:");

            if (DefaultVis == null)
            {
                DefaultVis = baseVertex.Get(@"To:\$Is:\$Is:\$DefaultOpenVisualiser:"); // yes. bad but it is
            }
            if (DefaultVis == null)
            {
                DefaultVis = baseVertex.Get(@"Meta:\$EdgeTarget:\$DefaultEditVisualiser:");
            }

            if (DefaultVis == null)
            {
                DefaultVis = MinusZero.Instance.Root.Get(@"System\Meta\Visualiser\Form");
            }

            if (GeneralUtil.CompareStrings(DefaultVis.Value, "Diagram"))
            {
                return(OpenDiagram(baseVertex, DefaultVis));
            }

            return(OpenVisualiser(baseVertex, DefaultVis));
        }
        public async Task <IActionResult> OnPostUpdate(DateTime ViewBookTime,
                                                       int ViewPallets, int ViewPort, int ActualArrivalHour,
                                                       int ActualArrivalMinute, int startHour, int startMinute,
                                                       int endHour, int endMinute, Guid ViewBookingId)
        {
            var booking = new UpdateBookingCommand()
            {
                BookingTime   = ViewBookTime,
                TotalPallets  = ViewPallets,
                Port          = ViewPort,
                ActualArrival = GeneralUtil.TimeFromHourAndMinute(ActualArrivalHour, ActualArrivalMinute),
                StartLoading  = GeneralUtil.TimeFromHourAndMinute(startHour, startMinute),
                EndLoading    = GeneralUtil.TimeFromHourAndMinute(endHour, endMinute),
                InternalId    = ViewBookingId
            };

            var result = await bookingDataService.UpdateBooking(booking);

            if (result.IsSuccesfull)
            {
                Message = "Bookingen er opdateret korrekt";
                return(new RedirectToPageResult("BookingSingle", new { id = ViewBookingId }));
            }

            return(new RedirectToPageResult("Error"));
        }
Ejemplo n.º 24
0
 public static void FloorModTest()
 {
     Assert(GeneralUtil.EuclideanMod(-1, 1), 0d);
     Assert(GeneralUtil.EuclideanMod(-2, 1), 0d);
     Assert(GeneralUtil.EuclideanMod(-1, 2), 1d);
     Assert(GeneralUtil.EuclideanMod(0, 2), 0d);
 }
Ejemplo n.º 25
0
        protected void AddEdge(IEdge e)
        {
            StackPanel p = new StackPanel();

            p.Margin = new Thickness(Margin);

            if (!GeneralUtil.CompareStrings(e.Meta.Value, "$Empty"))
            {
                TextBlock label = new TextBlock();
                label.Foreground      = (Brush)FindResource("0GrayBrush");
                label.Text            = e.Meta.Value.ToString();
                label.LayoutTransform = new ScaleTransform(Scale, Scale);

                p.Children.Add(label);
            }

            VisualiserEditWrapper w = new VisualiserEditWrapper();

            w.LayoutTransform = new ScaleTransform(Scale, Scale);

            w.BaseEdge = e;

            p.Children.Add(w);

            Children.Add(p);
        }
Ejemplo n.º 26
0
 public static void AngleDifferenceTest()
 {
     Assert(GeneralUtil.SubtractAngles(Math.PI / 2, -Math.PI / 2), Math.PI);
     Assert(GeneralUtil.SubtractAngles(Math.PI / 2, Math.PI / 2), 0d);
     Assert(GeneralUtil.SubtractAngles(-Math.PI / 2, Math.PI / 2), Math.PI);
     Assert(GeneralUtil.SubtractAngles(Math.PI * 3d / 4, -Math.PI * 3d / 4), Math.PI / 2);
 }
        /// <summary>
        /// Called when a click event happens on a selected course
        /// </summary>
        /// <param name="mx"></param>
        /// <param name="my"></param>
        private void ClickSpecificClass(int mx, int my)
        {
            if (returnButtonRect.Contains(mx, my))
            {
                state = CourseListState.ClassList;
            }

            if (dropButtonRect.Contains(mx, my))
            {
                HttpRequester.Default.DropCourse(selectedCourse.Key, (succ) =>
                {
                    if (succ.errorCode != null)
                    {
                        GeneralUtil.ShowError(succ);
                        return(false);
                    }

                    if (succ?.success == 1)
                    {
                        MessageBox.Show("Successfully dropped course.");
                    }

                    return(true);
                });

                List <Course> courses = HttpRequester.Default.GetEnrolledCourses();
                SetCourses(courses);
                state = CourseListState.ClassList;
            }
        }
Ejemplo n.º 28
0
        private void button2_Click(object sender, EventArgs e)
        {
            Log.LogInfo("Opening VDF file");
            DialogResult result = openDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                Log.LogInfo("Opening: " + openDialog.FileName);

                if (!File.Exists(openDialog.FileName))
                {
                    GeneralUtil.Error("File not found.");
                    return;
                }

                Editor editor = new Editor(this, recentItems);
                editor.OpenVDF(openDialog.FileName);
                recentItems.AddItem(openDialog.FileName);
                recentItems.Save();
                RefreshRecentItems();
                editor.Show();
                Hide();
            }
            else
            {
                Log.LogInfo("VDF Opening cancelled");
            }
        }
Ejemplo n.º 29
0
        protected void Data_Bind()
        {
            string tch_id = Session["account_user_id"].ToString();
            string sql1   = "SELECT course_schedule.course_schedule_id AS `课程编号`, course.course_name AS `课程名称`, class.class_name AS `教授班级`, course_schedule.course_schedule_type AS `课程类型`, course_schedule.course_schedule_status AS `课程状态` FROM ((class INNER JOIN department ON class.dept_id = department.dept_id) LEFT JOIN course_schedule ON department.dept_id = course_schedule.dept_id) LEFT JOIN course ON course_schedule.course_id = course.course_id WHERE tch_id = '" + tch_id + "'";

            GeneralUtil.GridViewInit(GridView1, sql1);
        }
Ejemplo n.º 30
0
        internal DbDriver GetDefaultDriver()
        {
            if (InnerDict.Count == 0)
            {
                foreach (ConnectionStringSettings item in ConfigurationManager.ConnectionStrings)
                {
                    if (!string.IsNullOrEmpty(item.ConnectionString) &&
                        !string.IsNullOrEmpty(item.ProviderName) &&
                        item.ElementInformation.IsPresent)
                    {
                        GeneralUtil.CatchAll(() =>
                        {
                            RegisterDbDriver(item.Name, item.ProviderName, item.ConnectionString);
                        }
                                             , true
                                             );
                    }
                }
            }

            // 获取去第一个
            foreach (string item in InnerDict.Keys)
            {
                return(InnerDict[item]);
            }

            return(null);
        }